Docker installation, image usage and some simple docker instructions

Docker is an open-source application container engine, which allows developers to package their applications and dependency packages into a portable container, and then publish them to any popular Linux machine. It can also realize virtualization. The container uses the sandbox mechanism completely, and there is no interface between them.

1.dock installation:
Prepare the installation package: community version docker17.03.1:

[root@foundation17 docker]# ls


[root@foundation17 docker]# yum install * -y

Open service:

[root@foundation17 docker]# systemctl start docker.service 

2. Add the image to the docker warehouse:

[root@foundation17 docker]# docker load -i game2048.tar 
011b303988d2: Loading layer [==================================================>]  5.05 MB/5.05 MB
36e9226e74f8: Loading layer [==================================================>] 51.46 MB/51.46 MB
192e9fad2abc: Loading layer [==================================================>] 3.584 kB/3.584 kB
6d7504772167: Loading layer [==================================================>] 4.608 kB/4.608 kB
88fca8ae768a: Loading layer [==================================================>] 629.8 kB/629.8 kB
Loaded image: game2048:latest

Run the image in the background and name it vm1:

[root@foundation17 docker]# docker run -d --name vm1 game2048

To view vm1 information:

[root@foundation17 docker]# docker inspect vm1

There will be an ip about the image here. Access the ip in the browser to run the image:

Browser access:

Attachment: some simple docker commands

1. After the dock runs, the system will add a docker device and assign an ip address:
ip addr view:

[root@foundation17 docker]# ip addr

Device docker0:

2. View docker version:

[root@foundation17 docker]# docker version 
 Version:      17.03.1-ce
 API version:  1.27
 Go version:   go1.7.5
 Git commit:   c6d412e
 Built:        Fri Mar 24 00:36:45 2017
 OS/Arch:      linux/amd64

To view doeker information:

[root@foundation17 docker]# docker info

To view the docker process:

[root@foundation17 docker]# docker ps

Port mapping: nginx service uses port 8080 on the local machine and port 80 in container vm2:

[root@foundation17 docker]# docker run -d --name vm2 -p 8080:80 nginx

Stop container:

[root@foundation17 docker]# docker container stop vm1
[root@foundation17 docker]# docker stop vm1

To view the history of mirror operations:

[root@foundation17 docker]# docker history game2048
IMAGE               CREATED             CREATED BY                                      SIZE                COMMENT
19299002fdbe        20 months ago       /bin/sh -c #(nop)  CMD ["/bin/sh" "-c" "se...   0 B                 
<missing>           20 months ago       /bin/sh -c #(nop)  EXPOSE 80/tcp                0 B                 
<missing>           20 months ago       /bin/sh -c #(nop) COPY dir:cb74e9c037a3d50...   600 kB              
<missing>           20 months ago       /bin/sh -c #(nop)  MAINTAINER Golfen Guo <...   0 B                 
<missing>           20 months ago       /bin/sh -c #(nop)  CMD ["nginx" "-g" "daem...   0 B                 
<missing>           20 months ago       /bin/sh -c #(nop)  EXPOSE 443/tcp 80/tcp        0 B                 
<missing>           20 months ago       /bin/sh -c #(nop) COPY file:d15ceb73c6ea77...   1.1 kB              
<missing>           20 months ago       /bin/sh -c #(nop) COPY file:af94db45bb7e4b...   643 B               
<missing>           20 months ago       /bin/sh -c GPG_KEYS=B0F4253373F8F6F510D421...   50.1 MB             
<missing>           20 months ago       /bin/sh -c #(nop)  ENV NGINX_VERSION=1.11.7     0 B                 
<missing>           22 months ago       /bin/sh -c #(nop)  MAINTAINER NGINX Docker...   0 B                 
<missing>           22 months ago       /bin/sh -c #(nop) ADD file:7afbc23fda8b0b3...   4.8 MB              

Interactive operation image:

[root@foundation17 docker]# docker run -it --name vm1 ubuntu

To delete a running container:

[root@foundation17 docker]# docker  rm -f vm1

Copy files to container:

[root@foundation17 docker]# docker  cp /etc/passwd vm1:/tmp

For more commands, please refer to docker – help:

[root@foundation17 docker]# docker --help

Keywords: Docker Nginx Linux CentOS

Added by ramas on Tue, 31 Dec 2019 15:14:51 +0200