安装
shell> apt-get -y install apt-transport-https ca-certificates curl software-properties-common
shell> curl -f sSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg| sudo apt-key add -
shell> add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
shell> apt-get -y update
shell> apt-get -y install docker-ce
配置国内镜像
shell> mkdir -p /etc/docker
shell> sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://qby02i3s.mirror.aliyuncs.com"]
}
EOF
shell> systemctl daemon-reload
shell> systemctl restart docker
启动
shell> systemctl start docker
停止
shell> systemctl stop docker
查看容器状态
shell> docker ps
shell> docker ps -a
拉取镜像
docker login registry.aisuhua.com -u aisuhua -p 123456
docker pull registry.aisuhua.com/aisuhua/phpdev
创建并运行容器
shell> docker run -v /www/web:/www/web -p 80:80 --dns 223.5.5.5 --name demo ubuntu
查看容器信息
shell> docker inspect demo
进入容器
shell> docker exec -i -t demo /bin/bash
停止容器
shell> docker stop demo
删除容器
shell> docker rm demo
复制文件到未运行的容器
shell> docker cp demo:/etc/supervisor/conf.d/program.conf .
shell> docker cp my_file demo:/www/web
停止和删除所有容器
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
删除所有 镜像
docker rmi $(docker images -f "dangling=true" -q)
自动启动容器
docker update --restart=always php72
docker update --restart=no php72