80. docker-ce 版本的安装(day80)

1

DockerHub github

docker  search      Search the Docker Hub for images

Docker registry àgitlab

Swarm Mesos k8s

2.

不指定虚拟机目录的挂载方式:

[root@localhost ~]# docker run -d --name nginx-volume-tests -v /data nginx

e57a78590a6fe47cdf145a39da56063d79612615af9d830b9ca95457c3b8450

(nginx-volume-tests为容器名,/data 表示将虚拟机的卷挂载到容器的data目录下,nginx为镜像)

接下来怎么查看虚拟机的哪个目录挂载到容器了呢???

[root@localhost ~]# docker inspect -f {{.Mounts}} nginx-volume-tests

[{volume 7f18e59432ee18028bee3f5a731d00510ff268029807c033193ddd5aee7aae3f /var/lib/docker/volumes/7f18e59432ee18028bee3f5a731d00510ff268029807c033193ddd5aee7aae3f/_data /data local  true }]

[root@localhost ~]# docker inspect -f {{   .Mounts   }} nginx-volume-tests

Template parsing error: template: :1: unexpected unclosed action in command

[root@localhost ~]#

指定虚拟机目录的挂载方式:

3.

#docker version: 显示Docker版本

#docker info: 显示Docker信息

4. 安装docker-ce 版本

4-1,sudo yum install -y yum-utils \

  device-mapper-persistent-data \

  lvm2

4-2sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo
4-3sudo yum-config-manager --enable docker-ce-edge
4-4sudo yum install docker-ce

-------------------------------
4-1,yum install -y yum-utils device-mapper-persistent-data lvm2
4-2,yum-config-manager --add-repo   https://download.docker.com/linux/centos/docker-ce.repo
4-3,yum-config-manager --enable docker-ce-edge
4-4,yum install docker-ce
-------------------------------




安装完成!!

systemctl start docker.service

systemctl enable docker.service

docker logs -f 238sf24d984 #持续监测容器日志的信息,相当于tail -f aa.logs

docker inspect 3278d565ce #显示容器的全部信息

5.注意!!!!

物理机的端口和docker 容器的端口没有做相应的映射的话就不能访问docker的应用。

6.暂停一个容器:

#docker pause t6232we #容器id

解除暂停容器

#docker unpause t6232we

拷贝一个镜像:

[root@192 ~]# docker images

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE

mynginx             v2                  f27b6ec6fc31        2 hours ago         293 MB

docker.io/centos    latest              49f7960eb7e4        5 weeks ago         200 MB

[root@192 ~]# docker tag mynginx:v2 mynginx:v4

[root@192 ~]# docker images

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE

mynginx             v2                  f27b6ec6fc31        2 hours ago         293 MB

mynginx             v4                  f27b6ec6fc31        2 hours ago         293 MB

docker.io/centos    latest              49f7960eb7e4        5 weeks ago         200 MB

[root@192 ~]#

7加速docker镜像

第一种方法:

[root@192 ~]# cd /etc/docker/

[root@192 docker]# ll

总用量 20

drwxr-xr-x. 5 root root    75 7月  11 20:43 certs.d

-rw-r--r--. 1 root root     3 5月  18 20:02 daemon.json

-rw-------. 1 root root   244 7月  11 20:45 key.json

-rw-r--r--. 1 root root 10837 5月  18 20:02 seccomp.json

[root@192 docker]# cat daemon.json

{}

[root@192 docker]# vim daemon.json

[root@192 docker]# systemctl daemon-reload

[root@192 docker]# systemctl restart docker

[root@192 docker]# cat daemon.json

{"registry-mirrors": ["http://12812674.m.daocloud.io"]}

[root@192 docker]#

猜你喜欢

转载自www.cnblogs.com/liuqiqi123/p/9302303.html