- Ubuntu Xenial 16.04 (LTS)
apt-get update
apt-getinstall apt-transport-https ca-certificates
apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys58118E89F3A912897C070ADBF76221572C52609D
source.list
deb https://apt.dockerproject.org/repo ubuntu-xenial main
apt-get install linux-image-extra-$(uname -r) linux-image-extra-virtual
apt-getinstall docker-engine
systemctl start docker
docker info
docker images
镜像:
1.最小
docker images hello-world
https://github.com/docker-library/hello-world
FROM scratch
ADD hello /
CMD ["/hello"]
2.基础
apline,或者其他官方提供的标准版镜像
tar cv--files-from/dev/null| dockerimport- scratch
- FROM scratch
- ADDscript.sh/usr/local/bin/run.sh
- CMD["/usr/local/bin/run.sh"]
基于cd
mount *.iso /mnt/cdrom
tar -C /media/cdrom -c . | docker import - *
debootstrap
/usr/share/debootstrap/scripts/
debootstrap [OPTION...] SUITE TARGET [MIRROR [SCRIPT]]
debootstrap trusty trusty > /dev/null
tar -C trusty -c . | docker import - trusty
docker mkimage
3.Dockerfile指令
4.network
--net="bridge"
Set the Network mode for the container
'bridge': create a network stack on the default Docker bridge
'none': no networking
'container:<name|id>': reuse another container's network stack(容器互联)
'host': use the Docker host network stack. Note: the host mode gives the container full access to local system services such as D-bus and is therefore
considered insecure.
'<network-name>|<network-id>': connect to a user-defined network
Set the Network mode for the container
'bridge': create a network stack on the default Docker bridge
'none': no networking
'container:<name|id>': reuse another container's network stack(容器互联)
'host': use the Docker host network stack. Note: the host mode gives the container full access to local system services such as D-bus and is therefore
considered insecure.
'<network-name>|<network-id>': connect to a user-defined network
5.volume
-v|--volume[=[[HOST-DIR:]CONTAINER-DIR[:OPTIONS]]]
Create a bind mount. If you specify, -v /HOST-DIR:/CONTAINER-DIR, Docker
bind mounts /HOST-DIR in the host to /CONTAINER-DIR in the Docker
container. If 'HOST-DIR' is omitted, Docker automatically creates the new
volume on the host.
Create a bind mount. If you specify, -v /HOST-DIR:/CONTAINER-DIR, Docker
bind mounts /HOST-DIR in the host to /CONTAINER-DIR in the Docker
container. If 'HOST-DIR' is omitted, Docker automatically creates the new
volume on the host.
host-dir:
名称:新建volume,/var/lib/docker/volumes目录
绝对路径:挂载该路径
--volumes-from=[] 共享volume
数据容器,然后其他容器共享此数据
备份恢复 tar
image
http://developers.redhat.com/blog/2016/02/24/10-things-to-avoid-in-docker-containers/