Docker virtualization technology

Web excerpt:
http://tech.uc.cn/?p=2726
http://dockerpool.com/static/books/docker_practice/index.html
http://yuedu.baidu.com/ebook/d817967416fc700abb68fca1?pn= 1

//http://mirrors.yun-idc.com/epel/6/x86_64/epel-release-6-8.noarch.rpm
//wget http://download.fedoraproject.org/pub/epel/6 /x86_64/epel-release-6-8.noarch.rpm

#docker native library
https://docs.docker.com/registry/deploying/

#centso7install docker
https://docs.docker.com/installation/centos/

CentOS 6 installation
1. Prepare the yum source to be installed (more troublesome)
    rpm -ivh epel-release-6-8.noarch.rpm

2. Install
yum update -y

yum install -y lxc libcgroup

yum install -y docker-io

3. Operation
service docker start
chkconfig docker on

##find image from docker hub
docker search centos #pull centos image
from docker hub
docker pull centos:6 #export
image (image id or name)
docker save tomcat > /tmp/tomcat.tar #Import

image
docker load < /tmp/tomcat.tar #View

image
docker images
docker images --no-trunc #Delete
image
docker rmi b5e4c1b6e097 #Delete

virtual machine (note that you need to check docker ps -a to check, docker stop d323rsa22asfda to stop)
docker rm d323rsa22asfda


is connected to the virtual machine
docker attach d323rsa22asfda #Start



docker container
-d: indicates background start
-p: port mapping
(run command includes create and start commands) #No
parameters are the default startup mode
docker run -i -t tomcat:latest #Port
mapping host's port 8888 can access port 8080 of the docker virtual machine
docker run -d -p 8888:8080 tomcat:latest
docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD =123456 mysql:latest
docker run --name mydb -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql:latest #Start
virtual machine with parameters
----docker run -i -t tomcatwh:latest "catalina.sh run"
----docker run -i -t mysqlwh:latest "/bin/bash"

stop the virtual machine
docker stop mydb
start the virtual machine
docker start mydb

check the status of the virtual machine
docker ps -l
docker ps -a

centso7 installation

#update
yum update -y

#Create a docker yum source
cat >/etc/yum.repos.d/docker.repo <<-EOF
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF

#Install docker
yum install docker- engine

#Start the docker service (there may be errors)
service docker start #Error

reason: off SELinux
vi /etc/sysconfig/selinux
reboot



docker images --tree #When the

docker network
ocker starts, it will create a file named docker0 on the host Virtual network interface,
172.17.42.1/16 is selected by default, a 16-bit subnet mask provides 65534 IP addresses for the container.
docker0 is just a virtual Ethernet bridge that automatically forwards packets between other network cards bound to it.
It enables containers and hosts to communicate with each other, and between containers and containers.

#delete docker0 bridge
service docker stop
ifconfig docker0 down
brctl delbr docker0

#Modify eth0 network card configuration file ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
BRIDGE=br0 #Add

bridge configuration file ifcfg-br0
DEVICE=br0
TYPE=Bridge
ONBOOT=yes
BOOTPROTO=static
IPADDR=10.0.0.101
NETMASK=255.255.255.0
GATEWAY=10.0.0.2 #Restart the

network
service network restart

#Modify the docker configuration file, use the br0 bridge
vi /etc/sysconfig/docker
other_args="-b=br0"

to exit the container but keep it running
By default , If you enter exit to exit the container, then the container will also stop and
press ctrl+p+q to exit to the host, while keeping the container still running

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326507341&siteId=291194637