docker1.12 installation configuration and usage notes

Source: Internet
Author: User
Tags docker run

Official Installation manual Address: https://docs.docker.com/engine/installation/linux/ubuntulinux/

The operating system used is ubuntu14.04, according to the official recommended configuration (other operating systems, how much a bit different please refer to the official documentation). The installation steps are as follows:

1. Check kernel version

Uname-r #把linux内核升级到3.10 or more

2. Apt's certificate verification and key

Apt-get updateapt-get Install Apt-transport-https ca-certificatesapt-key adv--keyserver hkp:// p80.pool.sks-keyservers.net:80--recv-keys 58118e89f3a912897c070adbf76221572c52609d

3. Add Source

Vim/etc/apt/sources.list.d/docker.listdeb Https://apt.dockerproject.org/repo ubuntu-trusty Mainapt-get Updateapt-get purge Lxc-docker #如果已经安装了, or install an older Docker.io uninstall Apt-get install linux-image-extra-$ (uname-r) Linux-image-extra-virtual #安装aufs存储必须包

4. Installing Docker

Apt-get Install Docker-engineservice Docker start

5, configure the domestic mirror

About Docker be sure to follow the official installation documentation, especially the ubuntu14.04 default apt installs the 1.9 older version, if the use of domestic mirrors will report what a mess of errors, upgrade to the latest version, problem solving

Curl-ssl https://get.daocloud.io/daotools/set_mirror.sh | Sh-s http://8db7f41f.m.daocloud.io# Check if a row was added successfully: docker_opts= "$DOCKER _opts--registry-mirror=http:// 8db7f41f.m.daocloud.io "Vim/etc/default/docker

6, Docker common commands to explain
A. Mirroring:
Image location:/var/lib/docker/aufs

docker commit              #容器名   centos:v1 , create image,-a author information  -m image information docker  version             #查看版本docker   search centos     # Search for available Docker images docker  images            # View current docker all mirrors docker  pull  centos       #下载镜像 (all relevant tags will be downloaded , suggest or add: Tag less download point) docker  push   name +tag     #上传镜像cat     centos.tar | docker import  -  centos6   #Docker导入镜像docker    export  id  > cenos6.tar                #Docker导出镜像docker  rmi  images          #删除镜像, preferably a warehouse name +tag (if you want more than one spaceOn the line), so that other labels with the same ID will not be deleted (just delete the label), if you want to delete all tags the same id, then directly enter the ID, will be deleted 

B. Container parts:

docker  run   centos echo  "Hello word"    #在docker容器中运行hello  world!docker  run  centos yum install ntpdate # Install the Ntpdate program in the container docker  ps -l                            # command to get the iddocker  ps  -a           of the last container                  #查看所有的容器. docker commit  Container name                     #提交刚修改的容器, e.g.:docker run -i -t centos /bin/bash         #在容器里启动一个/bin/bash shell Environment, you can log into the operation, where-t  means to open a terminal meaning,-I means you can input interactively. docker run -d -i -t centos /bin/bash     #在后台启动, exit to Ctrl+p, Q to continue backstage, not exit,exit is equivalent to close the container Docker attach container  id              # Enter this container after booting in the background docker run  -d  centos:v1  /bin/bash    #- D means start in the background and start in daemon mode. docker run -d -p 80:80 -p 8022:22 centos:latest /usr/bin/sshd -d   #端口映射docker  port  container name                         #查看端口映射情况docker  stop  container name                          #正常关闭容器docker  kill  container name                         #直接kill掉进程docker  start  id                          #  start a container, or change to docker start -i  container name docker rm  id                              #删除容器

D. Row bugs are commonly used:

Docker inspect ID #查看容器, mirroring status Docker logs-tf--tail 10 container name #最近10行容器内部运行情况docker Top container name #查 See the process of running containers

7. Docker independent IP and container interconnection

Ubuntu part

apt-get install bridge-utils     #安装brctl安装包service  docker stop               #停止dockerifconfig  docker0  down            #停止网卡brctl  show                         #查看物理机上有哪些网桥brctl  delbr docker0               #删除docker的默认网桥brctl  addbr br0                   #自定义网桥ifconfig  br0 192.168.180.22 netmask  255.255.255.0     #给网桥指定IP和子网vim  /etc/default/docker           #修改docker启动桥接DOCKER_OPTS = "$DOCKER _opts -b=br0" service docker  start             #启动dockerbrctl  show                        #查看是否生效

CentOS section
Service Docker stop
Ifconfig Docker0 Down
Brctl DELBR Docker0
cd/etc/sysconfig/network-scripts/

VI Ifcfg-eth0
Device=eth0
Bootproto=none
Onboot=yes
Type=ethernet
Bridge= "Br0"
Bootproto=static

VI ifcfg-br0
Device= "Br0"
Onboot=yes
Nm_controlled=no
Bootproto=static
Type=bridge
ipaddr=192.168.1.165
netmask=255.255.255.0
gateway=192.168.1.1
dns=192.168.1.50

Vi/etc/sysconfig/docker
Other_args= "-b=br0"

Service Docker start
[Email protected] ~]# Ps-ef|grep Docker
Root 5502 1 0 01:23 pts/3 00:00:00/usr/bin/docker-d-b=br0
Root 5800 5311 0 01:47 pts/3 00:00:00 grep Docker

Service Network restart
The following error may be reported:
Shutting down interface eth0: [OK]
Shutting down loopback interface: [OK]
Bringing up loopback interface: [OK]
Bringing up interface br0:determining if IP address 192.168.1.161 are already in use for device br0 ...
[OK]
Bringing up interface eth0:Error:Connection activation Failed:master Connection not found or invalid
[FAILED]
Workaround:
At this point, the current network adapter can also communicate, but after the network management tool to modify the IP, the current modification operation will not take effect. So how do you get rid of this hint?
In fact, the cause of the problem is redhat self-developed NetworkManager management tools and/ETC/SYSCONFIG/NETWORK-SCRIPTS/IFCFG-ETHX configuration is not synchronized caused. If you want to remove this hint, please close NetworkManager

Service can:
Chkconfig NetworkManager off
Service NetworkManager Stop
Stopping NetworkManager daemon: [OK]
At this point, the network service can then be reloaded:
Service Network restart
Shutting down interface br0: [OK]
Shutting down loopback interface: [OK]
Bringing up loopback interface: [OK]
Bringing up interface br0:determining if IP address 192.168.1.161 are already in use for device br0 ...
[OK]
Bringing up interface Eth0:device Eth0 is already a member of a bridge; Can ' t enslave it to bridge br0.
[OK]



8. Manually configure the static IP for the container
To install a new Iproute package:
wget https://repos.fedorapeople.org/repos/openstack/openstack-icehouse/epel-6/iproute-2.6.32-130.el6ost.netns.2.x86_64.rpm
Yum Localinstall iproute-2.6.32-130.el6ost.netns.2.x86_64.rpm

Install pipework:
git clone https://github.com/jpetazzo/pipework
CP ~/pipework/pipework/usr/local/bin/
To start the Docker container:
Docker RUN-ITD--net=none Jdeathe/centos-ssh:latest/bin/bash

Docker exec-it <container id>/bin/bash/So you're in the CONTAINER, and this bash exit won't affect the bash/before Docker run started.

Pipework br0 <container id> 192.168.1.170/[email protected]

9. Make a local Docker image that can be logged in SSH
Install the tools for making CentOS images:
Yum-y Install Febootstrap

Make CentOS image file Centos6-image directory:
Febootstrap-i bash-i wget-i yum-i iputils-i iproute-i man-i vim-minimal-i openssh-server-i openssh-clients CentOS 6 Centos6-image

http://mirrors.aliyun.com/centos/6/os/x86_64/

To make a docker image, the image name is centos6-base:
CD Centos6-image && tar-c | Docker Import-centos6-base

Make a docker image that can be ssh-landed, named Centos6-ssh:
Docker build-t Centos6-ssh Https://git.oschina.net/feedao/Docker_shell/raw/start/Dockerfile

With the previous six steps, a local Docker image that can be landed is ready to be made.
User name is: root, password is: 123456


This article is from the "lly0205.mofile.com" blog, make sure to keep this source http://481814.blog.51cto.com/471814/1850587

docker1.12 installation configuration and usage notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.