1. After Docker version 17.03

CE (Community Edition) ---- for free. EE (Enterprise Edition) ---- for freeCopy the code

2. Windows installation

1. Windows 10 2. Start Hyper-V 3. https://www.docker.com/get-docker click to Download the Desktop and Take a Tutorial, and Download the version of WindowsCopy the code

3. Linux installation

Lvm2 lvm2: y y yum install -y yum-utils device-mapper-persistent-data lvm2 2.2 Stable warehouse sudo yum - config - manager - add - repo https://download.docker.com/linux/centos/docker-ce.repo 3, install the docker (default install the latest version) Sudo yum install docker-ce docker-ce-cli containerd. IO 1. List and sort the versions available in your repository. This example sorts the results by version number, from highest to lowest. Yum list docker - ce - showduplicates | sort - r docker - ce. X86_64 3:18. 09.1-3. El7 docker - ce - stable docker - ce. X86_64 3:18.09.0-3.el7 docker-ce-stable docker-ce. X86_64 18.06.1. Ce-3. el7 docker-ce-stable docker-ce. X86_64 18.06.0.ce-3.el7 Docker-ce-stable installs a specific version by its full package name, which is the package name (docker-ce) plus the version string (the second column), from the first colon (:) up to the first hyphen, separated by a hyphen (-). For example, docker-CE-18.09.1. Sudo yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd. IO 4 Docker 5, Docker run sudo docker run hello-worldCopy the code

4. Introduction to docker management commands

Builder Manage Builds Config Manage Docker configs Container Manage Containers Context Manage Contexts Engine Manage the Docker engine Image Manage Images Network Manage Networks node Manage Swarm Nodes Secret Manage Docker secrets service Manage Services Stack Manage Docker Stacks Manage Swarm Manage Swarm Manage System Manage Docker Manage Trust Manage Trust on Docker images Manage Trust Volume Manage Volumes Managing data mounting (Data persistence === permanent)

5. Deploy ASPnetcore on Docker

Condition: 1, 2, Dockerfile vs2019 asp.net core project file 3, McR.microsoft.com/dotnet/core/aspnet:3.1-buster-slim mirror 4, McR.microsoft.com/dotnet/core/sdk:3.1-buster imageCopy the code

6, dockerfile instruction:

FROM: Specifies the base image (FROM is the required directive and must be the first directive).

RUN: Used to RUN command line commands. Its basic format:

Shell format: RUN < command >, enter the command in the bash environment, a dockerfile can RUN no more than 127 layers, so use RUN once, use a ‘\’ line feed, and use ‘&&’ to execute the next command. This format is generally used;

Exec format: RUN < “executable”, “parameter 1”, “parameter 2” >, this way is like the format in a function call;

COPY: copies files. Its basic format:

Format 1: COPY < source path >… < target path >

Format 2: COPY [“< source path 1> “,… “< destination path >”]

ADD: More advanced COPY files, ADD some functions on the basis of COPY, if the COPY is a compressed package, it will directly decompress, and do not need to use RUN decompress;

CMD: container start command. Its basic format:

Shell format: CMD < command >

Exec format: CMD [” executable “, “parameter 1”, “parameter 2″…]

Parameter list format: CMD [” Parameter 1 “, “Parameter 2″… After specifying the ENTRYPOINT directive, use CMD to specify the specific parameters

ENTRYPOINT: indicates the ENTRYPOINT. The basic formats are exec and shell,

The purpose of ENTRYPOINT, like CMD, is to specify the container launcher and parameters. ENTRYPOINT is an alternative to CMD in the runtime, but is more verbose than CMD and needs to be specified by the Docker run parameter – ENTRYPOINT. When ENTRYPOINT is specified, the meaning of CMD changes. Instead of running its commands directly, the contents of CMD are passed to the ENTRYPOINT directive as arguments. When executed, it becomes: “”

ENV: Sets environment variables. The basic format is:

Format 1: ENV

Format 2: ENV = =…

ARG: build parameters. Build parameters set environment variables in the same way ENV does, except that arGs build environment variables that do not exist in the future container runtime. Its basic format:

Format 1: ARG < parameter name > [=< default value >]

Format 2: This default value can be overridden in the build command docker build with –build-arg < parameter name >=< value >

VOLUME: defines an anonymous VOLUME. Its basic format:

Format 1: VOLUME [“< path 1>”, “< path 2> “…

Format 2: VOLUME < path >

EXPOSE: Exposes the port. The EXPOSE directive is a declaration of the ports provided by the runtime container, which will not be opened when the container is launched because of this declaration. Its basic format:

EXPOSE < Port 1> [< Port 2>…]

WORKDIR: specifies the working directory. Its basic format:

Format 1: WORKDIR < working directory path >

USER: Specifies the current USER. USER is to help you switch to the specified USER. Its basic format:

Format 1: USER < USER name >

HEALTCHECK: checks whether the container status is normal. Its basic format:

Format 1: HEALTCHECK [options] CMD < command > : sets the command to check the health of the container

Format 2: HEALTCHECK NONE: If the underlying mirror has a health check command, use this format to mask the health check command

Dockerfile core command

7.1. FROM Specifies a base image. 7.2. Copies files or directories from the context directory to the specified path in the container. COPY source path, target path COPY [" source path ", "target path "] RUN shell command parameter 1 Parameter 2 RUN ["shell command "," parameter 1"," parameter 2"] Example: RUN ["echo",">"," /usr/share/index.html"] CMD <shell command > CMD ["< executable file or command >","<param1>","<param2>",... For example, CMD ["dotnet","rmcore. DLL "] Disadvantages: Run can be overwritten docker run -d -p rmcore dotnet rmcore. DLL can be overwritten 7.5 ENTRYPOINT. ENTRYPOINT ["<executeable>","<param1>","<param2>",...] For example, ENTRYPOINT ["nginx", "-c"] specifies the CMD ["/etc/nginx/nginx.conf"] variable 7.6. To specify the port to be exposed during run, For example EXPOSE 5000 EXPOSE 5001 7.7, WORKDIR working directory directive is used to apply the working directory in the container. WORKDIR < work directory path > for example WORKDIR /rmcore or WORKDIR /nginxCopy the code

8, Docker how to build nginx image?

Nginx-1.15.2.tar. gz 2, basic mirror centos 3, nginx installation command 4, Dockerfile fileCopy the code

Nginx original configuration in Linux

# yum install GCC make pcre-devel zlib-devel tar zlib # yum install GCC make pcre-devel zlib-devel tar zlib http://nginx.org/download/nginx-1.15.2.tar.gz 3 nginx decompression/nginx tar - ZXVF nginx - 1.15.2. Tar. The four switch to gz/nginx/nginx - 1.15.2 /configure make make install 5 Switch to /usr/local/nginx/sbin and run./nginx to start nginxCopy the code

Configure nginx Dcokerfile

FROM centos RUN yum -y install GCC make pcre-devel zlib-devel tar zlib WORKDIR /nginx COPY nginx-1.15.2.tar.gz /nginx RUN tar -zxvf nginx-1.15.2.tar.gz RUN CD nginx-1.15.2 &&./configure && make && make install EXPOSE 80 CMD /bin/bashCopy the code

11. How does Docker do container choreography

How to use Nginx and RMCore at the same time?

Nginx Dockerfile file 2, rmcore Dockerfile 3, Services concept 4, docker-compose. Yml configuration file 5, docker-compose toolCopy the code

How?

Docker-compose installation 1.1, download url sudo curl -l docker-compose installation 1.1, download url sudo curl -l "Https://github.com/docker/compose/releases/download/1.24.1/docker-compose- (uname - s) - (uname -m)" - o /etc/usr/local/bin/docker-compose +x /usr/local/bin/docker-compose +x /usr/local/bin/docker-compose +x /usr/local/bin/docker-compose +x /usr/local/bin/docker-compose +x /usr/local/bin/docker-compose +x /usr/local/bin/docker-compose Docker-compose /usr/local/bin/docker-compose /usr/bin/docker-compose /usr/bin/docker-compose Build or rebuild the container service bundle Generate a Docker package from the compose file config verify and view the compose file create Create the container service down Stop and delete the container, network, image and volume Events receive live event exec from the container Run the help command in the running container images Image list kill Kill container logs View container logs pause Pause container service port Output port number ps container list pull Download container service image push Upload container service image Run Run the scale command to set the number of containers for the container service. Start Start container service. Stop Stop container service. Top Displays the running processes Version Docker-compose version information 2. Docker-compose. Yml file 2.1 YML file configuration is similar to that of json file configuration. https://www.runoob.com/w3cnote/yaml-intro.html 2.1.2 yml file configuration 1, object Companies, for example: {id: 1, name: company1, price: 200W} or companies: ID: 1 Name: company1 price: 200W 2, array For example, companies: [{id: 1,name: company1,price: 200W},{id: 2,name: Company2,price: 500W}] Companies: -id: 1 name: company1 price: 200w-id: 2 name: company2 price: 3, Basic variable type int float String Boolean Date datetime NULL 2.1 docker-compose.yml file configuration 2.1.1 Reference address https://docs.docker.com/compose/compose-file/ 2.1.2 core configuration version specified compose version The best is more than 3.0 version At present is the latest version 3.8 services configuration containers [list] [array] networks: [array] networks: [array] networks specify nginx-rmcore: Docker-composemess. yml how to configure nginx and rmcore? Docker-compose = docker-compose = docker-compose = docker-compose = docker-compose = docker-compose = docker-composeCopy the code