First, Docker the concept
Docker is an open-source application container engine that allows developers to package their applications and dependencies into a portable container, and then publish them to any popular Linux machine or virtualize them. Containers are completely sandbox-aware and do not have any interfaces with each other.
Second, the installation environment of Docker
1. Check the kernel version
# UNAME-R View current Linux version information
Docker requires CentOS7 with a minimum kernel version of 3.1
2. Turn off the firewall and SELinux
# Systemctl Stop Firewalld
# Setenforce 0
3. The solution to Docker container start appears networking won't work.
Vim/usr/lib/sysctl.d/00-system.conf
Add code
NET. IPv4. ip_forward=1
If you do not have this step, when you start the Docker container, it will appear
Warning:ipv4 forwarding is disabled. Networking won't work.
Third, the installation of Docker
# yum Install docker-y
# yum Install docker-devel-y (optional)
# Systemctl Start Docker open Docker service
# PS aux | grep Docker View Docker service = = "Ps-ef | grep Docker
Third, the internal installation nginx Docker
[[email protected] ~]# Docker search Nginx # Searching for nginx image files
INDEX NAME DESCRIPTION STARS official automated
Docker.io Docker.io/nginx official build of Nginx. 7835 [OK]
docker.io docker.io/jwilder/nginx-proxy Automated nginx Reverse proxy for Docker C ... 1251 [OK]
Docker.io docker.io/richarvey/nginx-php-fpm Container running Nginx + php-fpm capable ... 507 [OK]
Docker.io docker.io/jrcs/letsencrypt-nginx-proxy-companion letsencrypt container to use with Nginx as ... 292 [OK]
............................................................... The default is to select the first ..... ..... ................ ....................... ........
[[email protected] ~]# Docker pull docker.io/nginx download Nginx image
[[email protected] ~]# Docker images # view downloaded image file
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/nginx Latest 3f8a4339aadd 5 weeks ago 108.5 MB
# Docker Tag 3f8a4339aadd nginx:111 modify image name (optional)
Note: Please make sure that port 80 is not occupied. Netstat-lntup|grep80
[[email protected] ~]# Docker run-ti-d-P 80:80 docker.io/nginx /bin/bash # run Nginx container
Warning:ipv4 forwarding is disabled. Networking won't work.
bc134155f262031505cebd2978db3a35049d39f4c289711f5b3d89ced5e9497c
[[email protected] ~]# Docker PS # View a running container
Four, The internal launch Nginx Docker
[[email protected] ~]# Docker exec-ti bc134155f262 /bin/bash # Enter Nginx container contents
[Email protected]:/#/usr/sbin/nginx # launch Nginx
[Email protected]:/# # This tip means it's inside the container.
Open a new window
[Email protected] ~]# Curl 192.168.40.23
[Email protected] ~]# Curl 172.17.0.1
[Email protected] ~]# Curl 172.17.0.2
can be accessed locally to Nginx
V. SUMMARY of Docker commands
Docker Search Image name # searching for a corresponding mirror
# Download image file
Docker Pull Docker image name
# View the downloaded image
Docker images
# View a running container Docker PS # View all containers Docker ps-a# exit container Press Ctrl+d to exit the current container "but stop the container after exiting" # Exit does not stop container: Key combination: ctrl+p+q# start container Docker start container name or ID
Docker run-ti-d-P 80:80 Docker.io/nginx/bin/bash # for Nginx with ports and add commands to environment variables
Docker Pull hub.c.163.com/public/centos:7.0
Docker run--name mydocker-t-i-p 80:80 Hub.c.163.com/public/centos/bin/bash
# Enter container Docker attach container name or ID
Docker Exec-ti Bc134155f262/bin/bash # Stop container Docker stop container name or id# remove all containers--cautiously use Docker stop $ (Docker ps-q) & Docker RM $ (d Ocker Ps-aq)
Docker RMI container Name # Save container, generate mirror Docker commit container ID mirror name
# View container Linux versions in Docker container
Cat/etc/issue
# Copy files to the Docker internal container
Docker CP xxx.txt Docker container name or id:/xxx/xxx/xxxx
# Docker logs
Journalctl-u Docker.service
Original source http://blog.csdn.net/u011704394/article/details/54341402
Linux Transport Koriyuki Docker virtualization deployment Nginx