Mirroring
Get a mirror
Search from Docker Hub Mirror:
docker search ubuntu
Download Mirror:
docker pull ubuntu:18.04
If the image download slow change mirror source: Ubuntu 16.04 +, Debian 8 +, CentOS 7 in /etc/docker/daemon.json Please write the following (if the file does not exist Please new file)
{
"registry-mirrors": [
"https://dockerhub.azk8s.cn",
"https://reg-mirror.qiniu.com"
]
}
Note that we must ensure compliance with the json file specification, or Docker will not start.
After restarting the service.
sudo systemctl daemon-reload
sudo systemctl restart docker
Listed Mirror
docker images
docker image ls
Remove Mirror
docker image rm <image name>
Container operations
Open container
docker run --runtime=nvidia -it -v /home/:/home -p 8001:8001 centos7:py36 /bin/bash
-v 目录映射
-p 端口映射
Start container has been terminated
docker container start <container id>
Started termination container
docker container stop <container id>
Delete termination container
docker container rm <container id>
View container running
docker ps
View all containers
docker ps -a
Into the container
docker attach <container id> exit后容器会停止
docker exec -it <container id> bash exit后容器不会停止
Create a new image from the container
docker commit
docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
-a :提交的镜像作者;
-c :使用Dockerfile指令来创建镜像;
-m :提交时的说明文字;
-p :在commit时,将容器暂停。
Docker modifications within the container zone
apt update (为了安装tzdata)
apt install tzdata (为了获取/usr/share/zoneinfo)
rm /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
date (显示为当前时区时间)