【Docker】初识与应用场景认知
什么是Docker?###
Docker是一个容器化平台,它以容器的形式将您的应用程序及其所有依赖项打包在一起,以确保您的应用程序在任何环境中无缝运行。
什么是Docker容器?###
Docker容器包括应用程序及其所有依赖项,作为操作系统的独立进程运行.
什么是Docker镜像?###
Docker镜像是Docker容器的源代码,Docker镜像用于创建容器。
Docker的使用场景有哪些?###
①简化配置
②代码流水线管理
③提高开发效率
④隔离应用
⑤整合服务器
⑥调试能力
⑦多租户环境
⑧快速部署
八个Docker的真实应用场景:
Docker必备技能###
dcoker启动/关闭:######
sudo service docker start或
sudo systemctl enable docker \ sudo systemctl start docker
sudo service docker stop或
sudo systemctl stop docker
Docker Hello World######
运行交互式的容器######
启动容器(后台模式)######
#列出所有在运行的容器信息
docker ps
#在容器内使用docker logs命令,查看容器内的标准输出
docker logs CONTAINER ID/NAMES
停止容器######
docker stop CONTAINER ID/NAMES
#在容器内使用docker logs命令,查看容器内的标准输出
docker logs CONTAINER ID/NAMES
列出镜像列表######
查找镜像######
拖取镜像######
创建镜像######
当我们从docker镜像仓库中下载的镜像不能满足我们的需求时,我们可以通过以下两种方式对镜像进行更改。
1.从已经创建的容器中更新镜像,并且提交这个镜像.
2.使用 Dockerfile 指令来创建一个新的镜像.
①更新镜像
②我们使用命令 docker build , 从零开始来创建一个新的镜像。为此,我们需要创建一个 Dockerfile 文件,其中包含一组指令来告诉 Docker 如何构建我们的镜像。
设置镜像标签######
#我们可以使用 docker tag 命令,为镜像添加一个新的标签。
docker tag 860c279d2fec runoob/centos:dev
#docker tag 镜像ID,这里是 860c279d2fec ,用户名称、镜像源名(repository name)和新的标签名(tag)。
#使用 docker images 命令可以看到,ID为860c279d2fec的镜像多一个标签。
网络端口映射######
Docker使用###
Usage: docker COMMAND
A self-sufficient runtime for containers
Options:
--config string Location of client config files (default "/home/yunduo/.docker")
-D, --debug Enable debug mode
--help Print usage
-H, --host list Daemon socket(s) to connect to
-l, --log-level string Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info")
--tls Use TLS; implied by --tlsverify
--tlscacert string Trust certs signed only by this CA (default "/home/yunduo/.docker/ca.pem")
--tlscert string Path to TLS certificate file (default "/home/yunduo/.docker/cert.pem")
--tlskey string Path to TLS key file (default "/home/yunduo/.docker/key.pem")
--tlsverify Use TLS and verify the remote
-v, --version Print version information and quit
Management Commands:
container Manage containers
image Manage images
network Manage networks
node Manage Swarm nodes
plugin Manage plugins
secret Manage Docker secrets
service Manage services
stack Manage Docker stacks
swarm Manage Swarm
system Manage Docker
volume Manage volumes
Commands:
attach Attach local standard input, output, and error streams to a running container
build Build an image from a Dockerfile
commit Create a new image from a container's changes
cp Copy files/folders between a container and the local filesystem
create Create a new container
diff Inspect changes to files or directories on a container's filesystem
events Get real time events from the server
exec Run a command in a running container
export Export a container's filesystem as a tar archive
history Show the history of an image
images List images
import Import the contents from a tarball to create a filesystem image
info Display system-wide information
inspect Return low-level information on Docker objects
kill Kill one or more running containers
load Load an image from a tar archive or STDIN
login Log in to a Docker registry
logout Log out from a Docker registry
logs Fetch the logs of a container
pause Pause all processes within one or more containers
port List port mappings or a specific mapping for the container
ps List containers
pull Pull an image or a repository from a registry
push Push an image or a repository to a registry
rename Rename a container
restart Restart one or more containers
rm Remove one or more containers
rmi Remove one or more images
run Run a command in a new container
save Save one or more images to a tar archive (streamed to STDOUT by default)
search Search the Docker Hub for images
start Start one or more stopped containers
stats Display a live stream of container(s) resource usage statistics
stop Stop one or more running containers
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
top Display the running processes of a container
unpause Unpause all processes within one or more containers
update Update configuration of one or more containers
version Show the Docker version information
wait Block until one or more containers stop, then print their exit codes
Docker使用过程中遇到的问题:###
1.Docker启动Get Permission Denied https://www.cnblogs.com/informatics/p/8276172.html
原因:大概的意思就是:docker进程使用Unix Socket而不是TCP端口。而默认情况下,Unix socket属于root用户,需要root权限才能访问。
解决方法1:
使用sudo获取管理员权限,运行docker命令
解决方法2:
docker守护进程启动的时候,会默认赋予名字为docker的用户组读写Unix socket的权限,因此只要创建docker用户组,并将当前用户加入到docker用户组中,那么当前用户就有权限访问Unix socket了,进而也就可以执行docker相关命令:
sudo groupadd docker #添加docker用户组
sudo gpasswd -a $USER docker #将登陆用户加入到docker用户组中
newgrp docker #更新用户组
docker ps #测试docker命令是否可以使用sudo正常使用
2.Docker pull 出现的 error pulling image configuration: Get https://dseasb33srnrn.cloudfront.net/
https://blog.csdn.net/sfdst/article/details/69336273
systemctl stop docker
echo "DOCKER_OPTS=\"\$DOCKER_OPTS --registry-mirror=http://f2d6cb40.m.daocloud.io\"" | sudo tee -a /etc/default/docker
service docker restart
【Docker】初识与应用场景认知的更多相关文章
- Docker技术这些应用场景【转】
场景一:节省项目环境部署时间 1.单项目打包 每次部署项目到测试.生产等环境,都要部署一大堆依赖的软件.工具,而且部署期间出现问题几率很大,不经意就花费了很长时间. Docker主要理念就是环境打包部 ...
- Docker学习总结(11)——八个Docker的真实应用场景
[编者的话]Flux 7介绍了常用的8个Docker的真实使用场景,分别是简化配置.代码流水线管理.提高开发效率.隔离应用.整合服务器.调试能力.多租户环境.快速部署.我们一直在谈Docker,Doc ...
- docker --- 初识
Docker简介 Docker是一个开源的引擎,可以轻松的为任何应用创建一个轻量级的.可移植的.自给自足的容器.开发者在笔记本上编译测试通过的容器可以批量地在生产环境中部署,包括VMs(虚拟机).ba ...
- 浅析Docker容器的应用场景
本文来自网易云社区 作者:娄超 过去几年开源界以openstack为代表的云计算持续火了好久,这两年突然又冒出一个叫Docker的容器技术,其发展之迅猛远超预料.网上介绍Docker容器的文章已经很多 ...
- docker 初识1
学习网址 https://git.oschina.net/yangllsdev/docker-training https://docs.docker.com/engine/installation/ ...
- docker初识-docker安装、基于docker安装mysql及tomcat、基本命令
一.docker是什么 用go语言开发,开源的应用容器引擎,容器性能开销极低 二.整体架构图 Docker 包括三个基本概念: 镜像(Image):Docker 镜像(Image),就相当于是一个 r ...
- Docker初识
<Docker--从入门到实践>是Docker技术的入门教程,学习时长两天,现整理关键点如下: 1. 什么是Docker? 轻量级操作系统虚拟化解决方案:Go语言实现:下图很好地说明了Do ...
- docker 初识之二(简单发布ASP.NET Core 网站)
在发布ASP.NET Core网站以前,先介绍一下DaoCloud 一个免费的docker云容器服务平台.登陆官方网站,创建一台docker主机,这台主机有120分钟的使用时间,对于鄙人学习使用正好合 ...
- 1021 docker初识
docker与虚拟机相比,没有虚拟化内核,转而使用宿主机的内核.因此docker更轻更快 docker缺点:后端兼容性测试需求.把软件安装在不同的操作系统上进行测试,观察软件运行是否良好. 不能用do ...
随机推荐
- 【Django入坑之路】admin组件
1:settings.py 中的 INSTALLED_APPS # Application definition INSTALLED_APPS = [ 'django.contrib.admin', ...
- Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第十三章:计算着色器(The Compute Shader)
原文:Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第十三章:计算着色器(The Compute Shader) 代码工程 ...
- Mysterious Antiques in Sackler Museum(判断长方形)
题目链接 参考博客Ritchie丶的博客 - UVALive 7267 Mysterious Antiques in Sackler Museum (判断长方形) 题意:大概意思就是判断四个矩形能不能 ...
- this的作用
1.在一般函数方法中使用 this 指代全局 function test(){ this.x = 1; alert(this.x); } test(); // 1 2.作为对象方法调用,this ...
- 【转载】 C++ stl string 操作
总结一下C++中string的操作,来自〈C++ Primer〉第四版. 1. string对象的定义和初始化: 12345678910111213 string s1; //空串string ...
- APP UI设计趋势:为好设计而动
http://www.cocoachina.com/design/20150703/12029.html 作者:bone9 善心悦目的动效已然成为一个app的必备,作为设计师自然要跟随趋势学习.APP ...
- C# Find vs FirstOrDefault
本文告诉大家,在获得数组第一个元素时,使用哪个方法性能更高. 需要知道,两个方法都是 Linq 的方法,使用之前需要引用 Linq .对于 List 等都是继承可枚举Enumerable这时获取第一个 ...
- 网站的域名带www的和不带www的有什么区别呀
国内用户习惯用www,不过默认的不带www的域名要好过带www的,带Www的是二级域名,不带的是顶级域名,默认的在搜索引擎中得权重会比较高 区别就在于一个带www一个不带www 其他都一样.www的域 ...
- day2_python之字符编码
一 .计算机基础知识 二.文本编辑器存取文件的原理(nodepad++,pycharm,word) #1.打开编辑器就打开了启动了一个进程,是在内存中的,所以,用编辑器编写的内容也都是存放与内存中的, ...
- BiLSTM-CRF学习笔记(原理和理解) 维特比
BiLSTM-CRF 被提出用于NER或者词性标注,效果比单纯的CRF或者lstm或者bilstm效果都要好. 根据pytorch官方指南(https://pytorch.org/tutorials/ ...