3、保持docker运行,在宿主机shell中查看当前运行的容器
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d6ed588f5215 centos "bash" 2 minutes ago Up 2 minutes kickass_archimedes
5、查看新生成的镜像ID
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
zstdadi v1.0 4c8f4918193b 3 minutes ago 274 MB
6、运行新镜像
退出 docker shell
(docker)# Ctrl+D
再次进入新生成的镜像:
# docker run -it --device=/dev/net/tun --device=/dev/ppp --cap-add=net_admin 4c8f4918193b
查看容器
# docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3b8746d7c893 ubuntu "/init" 8 minutes ago Exited (0) 7 minutes ago elated_hopper
若状态是exited,则先启动
# docker start 3b8746d7c893
进docker的shell里,如果入口不是ssh
# docker exec -t -i elated_hopper sh
查看docker日志
# docker logs -f 3b8746d7c893
删除容器
# docker container rm 3b8746d7c893
查看镜像
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
zstdadi latest 3bd141a98b52 23 hours ago 395MB
删除镜像
# docker image rm 3bd141a98b52
三、安装中神通大地云控软件
1、拷贝文件到容器中
查看容器ID
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fd8eba2a9a7e 4c8f4918193b "bash" 7 minutes ago Up 7 minutes romantic_hamilton
2、如果中断会话,可以重新进入CONTAINER容器中
先查看当前容器ID
# docker ps
# docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fd8eba2a9a7e 4c8f4918193b "bash" 22 hours ago Up 22 hours romantic_hamilton
再attach进入容器
# docker attach fd8eba2a9a7e
3、在容器中安装中神通大地云控软件
(docker)# cd /root
(docker)# ls -alt
(docker)# chmod a+x install_v3.sh
(docker)# ./install_v3.sh
5、查看运行的容器CONTAINER暴露的端口
# docker ps
# docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
51d17af2f53a zstdadi:v1.2 "bash" 6 minutes ago Up 6 minutes 0.0.0.0:8080->888/tcp elated_mccarthy
6、查看日志# docker logs elated_mccarthy
五、注意事项
docker容器中:
1、不能mv 或 sed -i /etc/hosts hostname resolv.conf(缺省是宿主机的内容)
2、不能hostname 改名
hostname: you must be root to change the host name