1.linux上 下载镜像:docker run -it centos:7 sleep 1000000
2.先列出运行中的容器: docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9c360ee30424 centos:7 "sleep 1000000" 27 minutes ago Up 27 minutes gracious_kowalevski
5960e9291963 nginx "nginx -g 'daemon of…" 21 hours ago Up 21 hours 0.0.0.0:9100->80/tc
3.docker inspect 命令 :该命令用于获取容器/镜像的元数据
docker inspect 9c3
4.把docker文件拷贝到镜像文件目录里面
docker cp ./dcos_generate_config.sh 9c3:/root/
docker cp ./genconf 9c3:/root/
查看9c3镜像/root目录下的文件列表
docker exec -it 9c3 ls /root
5.进入docker镜像命令: docker exec -it 镜像Id或镜像name /bin/bash
例: docker exec -it 9c3 /bin/bash
6.ssh登录143
[root@9c360ee30424 genconf]#ssh -i ssh-key 10.3.65.143
bash: ssh: command not found
[root@9c360ee30424 genconf]# yum list installed | grep sshd
[root@9c360ee30424 genconf]# yum install -y sshd
2.先列出运行中的容器: docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9c360ee30424 centos:7 "sleep 1000000" 27 minutes ago Up 27 minutes gracious_kowalevski
5960e9291963 nginx "nginx -g 'daemon of…" 21 hours ago Up 21 hours 0.0.0.0:9100->80/tc
3.docker inspect 命令 :该命令用于获取容器/镜像的元数据
docker inspect 9c3
4.把docker文件拷贝到镜像文件目录里面
docker cp ./dcos_generate_config.sh 9c3:/root/
docker cp ./genconf 9c3:/root/
查看9c3镜像/root目录下的文件列表
docker exec -it 9c3 ls /root
5.进入docker镜像命令: docker exec -it 镜像Id或镜像name /bin/bash
例: docker exec -it 9c3 /bin/bash
6.ssh登录143
[root@9c360ee30424 genconf]#ssh -i ssh-key 10.3.65.143
bash: ssh: command not found
[root@9c360ee30424 genconf]# yum list installed | grep sshd
[root@9c360ee30424 genconf]# yum install -y sshd