How to deal with Docker in half a day and Docker in half a day
In fact, the volume ker is still very limited in real business scenarios. The Dockerfile script is not so easy to write, and some applications are not so well installed.
Don't talk nonsense. Teach you how to deal with docker for half a day!
Install dependencies and docker
Http://down.51cto.com/data/699208 download path
Rpm-ivh epel-release-6-8.noarch.rpm
Yum install docker-io-y
Start docker
Service docker start
Search for public container Images
Docker search centos6.6
Fuzzy search is supported, but do not think about how good a public container is. You need to build your own suitable business.
NAME DESCRIPTION STARS OFFICIAL AUTOMATEDliangtong/centos6.6-httpd 2 incu6us/centos6.6-with-nginx Wav server for FreeCall 0 [OK]eliezio/centos6.6-devtoolset2-gtest Docker image based on Centos 6.6 suitable ... 0 [OK]chrisgeorge/centos6.6-py2.6 CentOS 6.6 with Python 2.6 0 [OK]leonion/centos6.6 centos6.6 0 heilee/centos6.6 0 karthi12345/centos6.6 0 kalramain/centos6.6-mysql55 mysql5.5 installed on centos6.6 0
Attach an image container
Docker pull chrisgeorge/centos6.6-py2.6 <NAME>
Trial Run
Docker run-I-t chrisgeorge/centos6.6-py2.6/bin/bash
In this way, you can log on to your pre-designed container.
Install an application
Yum install openssh-server
# Modify the content in the/etc/ssh/sshd_config file
PermitRootLogin yes
UsePAM no
Ssh-keygen-q-N ""-t dsa-f/etc/ssh/ssh_host_dsa_key
Ssh-keygen-q-N ""-t rsa-f/etc/ssh/ssh_host_rsa_key
Mkdir/var/run/sshd
Passwd logon Password
/Etc/init. d/sshd start
Update Image
Docker commit ID <name>
Delete an image
# Docker rmi <neme>
Start
Docker run-d-p 22-p 8022: 8000 chrisgeorge/centos6.6-py2.6/usr/sbin/sshd-D
Map port 8000 of the container to port 8022 Of The docker server, and randomly map port 22 of the container
[root@SERVER docker]# docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES0c65edbc3f3d wy "/usr/sbin/sshd -D" 22 minutes ago Up 22 minutes 0.0.0.0:32769->22/tcp, 0.0.0.0:8022->8000/tcp mad_poitras
Backup Image
Docker save chrisgeorge/centos6.6-py2.6>/root/docker-pmd.tar
Restore an image
Docker load </root/docker-pmd.tar
To run an image, docker must be installed on each machine.
Dockerfile
Script:/home/docker/Dockerfile
FROM chrisgeorge/centos6.6-py2.6 # inherited parent container MAINTAINER wonter # RUN yum install nginx # install nginxRUN echo "root: root "| chpasswd # Set Password EXPOSE 22 # Set port CMD/etc/init. d/nginx start # start the service
# Docker build-t wonter.