最近,使用 docker
部署了 Jenkins
,为了便于以后查阅,记录一二于此。
拉取镜像
docker pull
查看当前主机所有 docker
镜像
docker images
运行 docker
docker run -d -it --rm
其中, -d
表示后台运行。
进入 docker
终端
docker exec -it container_id /bin/bash
保存 docker snapshot
docker container commit
保存镜像到文件
docker save
migrate container from a host to another host
Export containers
docker export container-name | gzip > container-name.gz
Import containers
zcat container-name.gz | docker import - container-name
Note that the imported container should be tagged before use with docker
or docker-compose
. For example:
docker tag c875a77ec739 centos6-i386:20220321
Network issue resolved
Since I have already defined the network in the docker-compose yaml file, but also failed start the container with the following message.
user specified IP address is supported only when connecting to networks with user configured subnets
Maybe this is because the network already exists in the system, so you can use docker network ls
command to list all networks. If exists then you can remove it with docker network rm
command and have a try to start with docker-compose.
Reference:
https://bobcares.com/blog/move-docker-container-to-another-host/