docker容器安装部署
docker容器安装部署
1.下载docker-ce-selinux、docker-ce的rpm包
https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch.rpm
https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-17.03.0.ce-1.el7.centos.x86_64.rpm
2.将上述两个rpm包上传到linux系统/docker目录下
3.进入/docker目录
cd /docker/
4.安装docker
yum -y install *
5.开启docker服务
systemctl start docker
systemctl enable docker
6.测试docker是否正常开启
docker run hello-world
6.1报错
a.报以下错误
Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: TLS handshaketimeout
解决方法:
通过dig @114.114.114.114 registry-1.docker.io找到可用IP地址
#若上述命令报以下错误
-bash: dig: command not found
#安装bind-utils
yum -y intall bind-utils
#dig命令语句运行成功,找到以下信息
;; ANSWER SECTION:
registry-1.docker.io. 600 IN A 3.210.179.11
#在本地hosts添加以下信息
vim /etc/hosts
3.210.179.11 registry-1.docker.io
b.报以下错误
error pulling image configuration: Get https://dseasb33srnrn.cloudfront.net/
解决办法:
systemctl stop docker
echo "DOCKER_OPTS=\"\$DOCKER_OPTS --registry-mirror=http://f2d6cb40.m.daocloud.io\"" | sudo tee -a /etc/default/docker
systemctl start docker
7.成功标志
信息字段内含有Hello from Docker!,即表示成功。
[root@docker docker]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:f9dfddf63636d84ef479d645ab5885156ae030f611a56f3a7ac7f2fdd86d7e4e
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/