docker使用命令记录

安装

centos:
sudo yum install -y docker
拉取镜像

国内镜像daocloud.io
docker run daocloud.io/library/ubuntu:latest
运行

docker run -t -i daocloud.io/library/ubuntu:latest /bin/bash
查看信息

docker images
容器

启动容器服务器
service docker start
启动容器
docker run -d ubuntu /bin/sh -c “while true; do echo hello world;sleep 1; done”
查看容器日志
docker ps
ce7
docker logs ce7
终止容器
docker stop ce7
查看所有容器
docker ps -a -q
service docker start
service docker restart

进入容器
docker run -idt ubuntu
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b47f1d8d2e82 ubuntu “/bin/bash” 5 seconds ago Up 2 seconds vigilant_mclean

docker attach vigilant_mclean
dockerfile

从容器里面拷贝文件到宿主

docker cp 容器名:容器里面的路径 宿主机的响应路径
容器名docker ps ->names
进入容器内

docker ps ->find names or CONTAINER ID
docker exec -it 168b8e11a1c2 bash
docker exec -i -t 7820020baec2 /bin/bash
docker exec --help
-i, --interactive Keep STDIN open even if not attached
–privileged Give extended privileges to the command
-t, --tty Allocate a pseudo-TTY

你可能感兴趣的:(容器)