Docker-ce运用一:创建虚拟机
1、从远程仓库查看所需镜像
[root@localhost docker]# docker search centos8
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
2233466866/centos8 https://hub.docker.com/r/2233466866/centos8 4
thinakar/centos8 centos8 core with net-utils, vim, sshuttle 0
memiiso/centos8-java8python3docker centos8-java8python3docker 0
memiiso/centos8-java8python3 centos8 With java8 and python3 0
nmstate/centos8-nmstate-dev 0
prestocpp/centos8-gcc9 0
wuykimpang/centos8-extended 0
memiiso/centos8-java8 centos8-java8 0
alekseychudov/centos8-systemd CentOS 8 based systemd image 0
sharpreflections/centos8-build CentOS8 with development tools 0
ydli/centos8 centos8.2 with ansible-2.9.10, awscli-1.18.8… 0
vglad/centos8 Based on official latest CentOS 8 image with… 0
8378006361/centos8.2.2004 0
loging/centos8-python37 centos8 + python3.7.5 0
krestomatio/centos8-minimal Testing a Centos 8 minimal container image l… 0
2、从远程仓库拉取所需镜像
[root@localhost docker]# docker pull alekseychudov/centos8-systemd
Using default tag: latest
latest: Pulling from alekseychudov/centos8-systemd
2b7820d659b3: Pull complete
Digest: sha256:a03592eb8be9af3c6c910d209b7d231a4aee19d42c72082ec6a3b021f323516b
Status: Downloaded newer image for alekseychudov/centos8-systemd:latest
docker.io/alekseychudov/centos8-systemd:latest
3、查看下载到本地镜像
[root@localhost docker]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql latest e3fcc9e1cc04 12 days ago 544MB
osism/kolla-ansible queens-latest cfb5bad016bd 5 months ago 302MB
alekseychudov/centos8-systemd latest e13569384aea 6 months ago 256MB
4、创建容器
[root@localhost docker]# docker run -dit --name=centospy3 e13569384aea /bin/bash
7424ba3acdd87e4d65e8a3635914acf8152a745ec019e1f4cbd8873cd26f7f47
5、查看创建容器
[root@localhost docker]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7424ba3acdd8 e13569384aea "/bin/bash" 2 minutes ago Up 2 minutes centospy3
6、进入容器
[root@localhost docker]# docker exec -it centospy3 /bin/bash
[root@7424ba3acdd8 /]#
故障1:客户机192.168.10.103与docker本地仓库192.168.10.102网络不通;
[root@localhost docker]# docker push 192.168.10.102:5000/client102-hello-world
The push refers to repository [192.168.10.102:5000/client102-hello-world]
Get https://192.168.10.102:5000/v2/: dial tcp 192.168.10.102:5000: connect: no route to host
解决办法:查看网卡接口是否打开
[root@localhost docker]# nmcli connection
NAME UUID TYPE DEVICE
ens33 c96bc909-188e-ec64-3a96-6a90982b08ad ethernet ens33
ens34 94aea789-efb3-ef4c-81b0-e8b18ecc9797 ethernet ens34
docker0 9fd5b1df-f8fc-4a54-a9b3-59119a6838ce bridge docker0
[root@localhost docker]# nmcli c up ens33
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7)
故障2:docker本地仓库的端口5000没有开启,通过本地防火墙开放端口
[root@localhost ~]# firewall-cmd --get-active-zones |
查看防火墙活动区域 |
public
interfaces: ens33 ens34
[root@localhost ~]# firewall-cmd --zone=public --list-ports |
查看防火墙的已开放端口 |
5000/tcp
[root@localhost ~]# firewall-cmd --zone=public --add-port=5000/tcp --permanent |
在public区域开放端口5000 |
success
[root@localhost ~]# firewall-cmd --zone=public --query-port=5000/tcp |
查看端口5000是否开放 |
yes
[root@localhost ~]# firewall-cmd --reload |
重启软件防火墙 |
Success
[root@localhost ~]# systemctl restart firewalld.service |
重启防火墙服务 |
故障3:报错“ http: server gave HTTP response to HTTPS client”
解决办法:
[root@localhost /]# vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://55660wdp.mirror.aliyuncs.com"],
"insecure-registries": ["192.168.10.102:4000"] |
设定非安全注册为http |
}