Docker: Usage instruction

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

 

posted on 2016-10-27 18:01  三叁  阅读(362)  评论(0编辑  收藏  举报

导航