Docker containers mirroring

docker image

Base image: no parent mirroring Mirror
Mirror Gets: sudo docker pull ubuntu: 12.04 == sudo docker pull registry.hub.docker.com/ubuntu:12.04

Source configuration:
{ "Registry-Mirrors": [ " https://docker.mirrors.ustc.edu.cn "]}
The link address is USTC accelerator, without registration.
Run into force
systemctl-daemon reload
systemctl restart Docker

Container starts:

sudo docker run -t -i ubuntu:14.04 /bin/bash

Container changes submitted:

docker tag ubuntu: 15.10 runoob / ubuntu : v3 can play tag for this version, so after the tag will generate a new image
sudo docker commit -m "Added json gem " -a "Docker Newbee" 0b2616b0e5a8 ouruser / sinatra: v2
which, -a -m to specify descriptive information submitted by the user can specify the updated information; after container ID is used to create a mirror; the last name of the target designated warehouse mirror and tag information. Once created will return the ID information mirroring.

Dockerfile (each instruction is mirrored layer)
# This is a comment
FROM ubuntu:14.04 #指定基础镜像
LABEL version="1.0"  为镜像指定标签
MAINTAINER "donghao" 指定作者
ENV <key>=<value> ... 指定虚拟环境
语法有两种
1. ENV <key> <value>
2. ENV <key>=<value> ...
两者的区别就是第一种是一次设置一个,第二种是一次设置多个
Docker container
Start container

RUN Ubuntu Docker: 14.04 / bin / bash 'Docker Started'
Docker RUN -itd Ubuntu: # 14.04 bash terminal starts a bash, allow user interaction
-t option allows Docker assigned a pseudo-terminal (pseudo-tty) and bind to a container the standard input, -i standard container so that the input remains open
-d polymorphic forms daemon running
docker start containerID

Steps
检查本地是否存在指定的镜像,不存在就从公有仓库下载
利用镜像创建并启动一个容器
分配一个文件系统,并在只读的镜像层外面挂载一层可读写层
从宿主主机配置的网桥接口中桥接一个虚拟接口到容器中去
从地址池配置一个 ip 地址给容器
执行用户指定的应用程序
执行完毕后容器被终止
Export and import container

Export:
sudo Docker Export 7691a814370e> ubuntu.tar
Import:
CAT ubuntu.tar | sudo Docker Import - the Test / Ubuntu: v1.0
the URL of the form of import:
sudo Docker Import http://example.com/exampleimage.tgz Example / imagerepo

In the long run delete container

docker rm -f xxx

Guess you like

Origin www.cnblogs.com/donghaoblogs/p/12172434.html