Docker is an open-source application container engine that allows developers to package their apps and dependencies into a portable container and post them to any popular Virtualization can also be implemented on Linux machines . With Docker, it's the gospel for both operations and development. Directly below the configuration:
CentOS Install Docker Source:
Yum Install http://mirrors.yun-idc.com/epel/6/i386/epel-release-6-8.noarch.rpm
Installing Docker:
Yum Install-y Docker-io
To start Docker:
Service Docker start
If you start an error:
/usr/bin/docker:symbol Dm_task_get_info_with_deferred_remove, version Base not defined in file libdevmapper.so.1.02 With Link Time reference
Solution: Yum Install Device-mapper-event-libs
Then start Docker again.
Docker can create this warehouse, or it can submit the image to the public repository, and the following is the creation of the local repository:
To create a local warehouse:
Docker run-d-P 5000:5000 Registry
After the creation is complete, you will find that using Docker push cannot be uploaded at this time:
Note HTTPS authentication is required: Modify/etc/init.d/docker
Increase:
docker_opts= "--insecure-registry 192.168.1.231:5000" # #我的ip为192.168.1.231, modified according to the actual situation
Change $exec-D $other _args &>> $logfile & to $exec-d $DOCKER _opts &>> $logfile &
Restart Docker and push again is OK.
Service Docker restart
The initial construction was completed. Here is how to build bridge communication between multiple servers.
Precautions:
1.docker After you start the container, or create a bridge by default, and automatically assign an IP to the container that starts, this time the container and the host are interlinked, but not with the other hosts.
If you want to communicate with other containers, you can set up your own network bridge, the physical network card into the Network Bridge, and at this point, the container must be manually given to the IP (pipeword), or it will cause the LAN can not be connected to the Internet
To set up a custom network bridge, modify the network configuration:
Cp/etc/sysconfig/network-scripts/ifcfg-eth1/etc/sysconfig/network-scripts/ifcfg-br0
Vi/etc/sysconfig/network-scripts/ifcfg-br0 join:
Device= "Br0"
Onboot=yes
Type= "Bridge"
Bootproto=ststic
ipaddr=192.168.1.215
netmask=255.255.255.0
gateway=192.168.1.1
dns=119.6.6.6
Defroute=yes
vi/etc/sysconfig/network-scripts/ifcfg-eth1# #将网卡加入网桥
Device=eth0
hwaddr=00:0c:29:a2:9e:53
Type=ethernet
Onboot=yes
Nm_controlled=yes
Bootproto=none
Bridge=br0
#IPADDR =192.168.1.215
#NETMASK =255.255.255.0
#GATEWAY =192.168.1.1
Restart Service Network restart
Delete previous bridges: # #docker0 automatically created when you start a container
IP link set Dev Docker0 down
Brctl DELBR Docker0
To view the Network bridge:
Brctl show# #此时可以看见了eth0已经加入到网桥了
Start the container, do not automatically assign IP, otherwise it will cause LAN can not add--name xxx--net=none
Eg:docker run-it--name 123--net=none Centos/bin/bash
To set a static IP using the pipe tool:
git clone https://github.com/jpetazzo/pipework
Go directly to the pipework directory:
./pipework br0# #网桥名称 123# #容器名称 192.168.1.175/[email protected]##@ is behind the gateway and can be communicated with other hosts at this time
Settings may be error: Object "Netns" is unknown, try "IP Help"
Workaround: RPM-UVH https://repos.fedorapeople.org/openstack/EOL/openstack-grizzly/epel-6/ iproute-2.6.32-130.el6ost.netns.2.x86_64.rpm
Once you're done, you can set up IP. You can enable Brctl show to see one more network card. Enter the container to see that the IP is set to complete
To configure SSH login:
Yum Install Openssh-server-y
Mkdir-p/var/run/sshd
/usr/sbin/sshd-d &
To modify the secure login configuration of the SSH service, cancel the PAM login limit:
Comment out the session required pam_loginuid.so
Mkdir/root/.ssh
Cd/root/.ssh
Ssh-keygen-t rsa# #生产公钥
passwd Root
Xxx
Xxx
Finally create a startup script
vi/root/run.sh
#!/bin/bash
/usr/sbin/sshd-d
chmod +x/root/run.sh
The last commit image can be
To start the container:
Docker run-d centos/root/run.sh# #ssh服务自动开启, you can log in by IP and password, install what you want to install, and commit.
This article is from the "Nginx Installation Optimization" blog, please be sure to keep this source http://mrdeng.blog.51cto.com/3736360/1768771
CentOS installation deployment Docker with LAN host connection details configuration