Docker: Usage instruction

本文介绍了如何在Windows和Linux上安装Docker,并提供了运行基本Docker容器的步骤。此外,还详细说明了如何通过SSH进入容器内部,备份及恢复Docker容器,以及一些常用的Docker命令。

Install docker from official site, in windows.

or install docker from repo as official site told, in linux..

after installation, we run by: (windows service, linux daemon started)

docker run hello-world/centos/..

where the names can be found here.

most used args are -it, --rm, --read-only.., -p 80:80, --ip ..

docker ps -sa
# docker --help
# docker command --help

to view history docker machines.

For example, common download size of centos is 80MB, less than 0.1GB, light.

 

how to access docker lxc?

first ssh to the host of the lxc, then use container's pid to get into lxc, by:

docker inspect <name of container> |grep Pid
nsenter --target $PID --mount --uts --ipc --net --pid

run a docker gerrit:

docker pull gerritforge/gerrit-centos7
docker run -d -p 8080:8080 -p 29418:29418 gerritforge/gerrit-centos7

docker backup:

# back up & export
docker commit -p -m "mark" hash-id  # the -p means pause the container while commiting
docker save hashid -o file.tar
# load & run
docker load -i file.tar
docker images
docker start hash-id

restart docker with new conf:

# get containername
docker ps -sa
# create new image from container
docker commit containername imagename
# start new container from newly created image
docker run --name newcontname -p80:80 -p9001:9001 -p9038:9038 -v/Users/zuiyou/bin:/opt/bin -v/Users/zuiyou/GO/data/golang:/data/golang -it imagename /bin/bash
# connect
docker exec -it newcontname

 

转载于:https://www.cnblogs.com/sansna/p/6004956.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值