1. Docker installation and settings #Install CentOS and put the Docker package in the Extras software source. You can use it directly: yum install docker-io -y #View the version of docker docker -v #Start the Docker service systemctl start docker.service #Start the Docker service systemctl enable docker.service #Check the startup status of the Docker service systemctl status docker.service #Restart the Docker service systemctl restart docker.service 2. Create a new Net Core program 1. Create a new Net Core project. Note: Docker support is not enabled. 2. Publish the newly created project (target runtime: portable) 3. Create a new Dockerfile file in the published folder (without suffix) The general contents are as follows: FROM microsoft/dotnet:2.1-aspnetcore-runtime //Note that your version must match WORKDIR /app COPY . . //Copy all files in the current directory (except the paths excluded by .dockerignore) to the /app directory of the image file. EXPOSE 5000 //Port number (expose the container port 5000 to allow external connections to this port.) //EXPOSE 443 //Https port is opened ENTRYPOINT ["dotnet", "DockerDemo5.dll"] //Change the running assembly to your own 3. Upload the published project to the Linux server (CentOS) 1. Enter the release directory of the program #Enter the release target of the program cd /data/web/mydocker #Create an image file (-t parameter is used to specify the name of the image file, and a colon can be used to specify the label after it. PS: Note the last dot) docker build -t aspnetcoredocker1.1 . #Generate a container. Each time you run it, a new container will be created (the 5000:5000 here means mapping port 5000 in the container to port 5000 on your host, with the container port at the end) docker run -it -p 5000:5000 aspnetcoredocker1.1 #docker run -it -p 5000:5000 aspnetcoredocker1.1:TAG // The default TAG is latest 2. Just access it directly 3. Automatically start the docker container (after the container exits or is powered off, docker can specify the restart strategy by using the --restart parameter when creating the container) # Set the startup strategy docker run --restart always -it -p 5000:5000 aspnetcoredocker1.1 #If the container has been created, we want to change the restart policy of the container docker update --restart always 3ec28be7254a //Container ID # --restart Multiple parameter values select no to not automatically restart the container. (Default value) on-failure The container exits when an error occurs (the container exit status is not 0) and restarts the container. You can specify the maximum number of restarts, such as: on-failure:10 Unless-stopped Restart the container only when the container has been stopped or Docker is stopped/restarted. Manual stop does not count. Always Restart the container only when the container has been stopped or Docker is stopped/restarted. 4. Docker related commands Image files and container commands #View all docker images #Delete an image with imageid docker rmi [IMAE_ID] #Delete all images sudo docker rmi $(docker images -q) #View the running status of all containers docker ps -a docker container ls -all #Delete a container with containerid (instance) docker rm 6f0c67de4b72 #Delete all containers docker rm $(sudo docker ps -a -q) Container logs #View the logs after the specified time, and only display the last 100 lines: docker logs -f -t --since="2019-06-08" --tail=100 CONTAINER_ID #View the log after a certain time: docker logs -t --since="2019-06-08" CONTAINER_ID #View logs for a certain period of time: docker logs -t --since="2019-06-08" --until "2019-06-09" CONTAINER_ID #View the logs for the last 30 minutes: docker logs --since 30m CONTAINER_ID The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Testing of hyperlink opening target
>>: Solve the problem of not finding NULL from set operation to mysql not like
Problem Description When we are working on a proj...
Table of contents 1. Introduction to Concurrency ...
Table of contents What is Vuex? Vuex usage cycle ...
In the field of data analysis, database is our go...
Use of stored procedure in parameters IN paramete...
1. Radio grouping As long as the name is the same,...
A dynamic clock demo based on Canvas is provided ...
This article introduces the sample code of CSS3 t...
Install Docker Update the yum package to the late...
Hello everyone, today I will share with you the W...
Problem Description The button style is icon + te...
This article example shares the specific code of ...
Table of contents 1. Overview 2. Name field 3. Ve...
Preface In MySQL, both Innodb and MyIsam use B+ t...
This article shares the specific code of using ca...