docker入门

  • 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
  1. FROM scratch
  2. ADDscript.sh/usr/local/bin/run.sh
  3. 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

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.
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/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值