Detailed asp.net Core docker deployment _docker

Source: Internet
Author: User
Tags dotnet docker ps docker run


Objective



In the previous article, we described the release and deployment of ASP.net core on macos,linux based on Nginx and Jexus, and this article is mainly about how to run Docker core applications in the ASP.net container.



asp.net Nginx release and deployment: Http://www.cnblogs.com/savorboard/p/dotnet-core-publish-nginx.html.



asp.net Jexus release and deployment: Http://www.cnblogs.com/savorboard/p/dot-net-linux-jexus.html.



Directory


    • Docker Common Commands
    • Docker install asp.net core image
    • Using Dockerfile Deployment


Docker Common Commands


Docker info


Check that the Docker is installed correctly and that if this command is not found, the Docker is not installed correctly


Docker Pull BusyBox


Pull a pre-built mirror


sample_job=$ (Docker run-d busybox/bin/sh-c "while true; Do Echo Docker; Sleep 1; Done ")


The way the next process runs Hello Docker



The sample_job command prints once every second docker, using Docker logs to view the output. If you don't have a name, the job will be assigned an ID, and using commands such as Docker logs to view the log later becomes more cumbersome.


Docker logs $sample _job


Run the Docker logs command to view the current status of the job:


Docker Help


All Docker commands


Docker Stop $sample _job


Stop a container named Sample_job


Docker Restart $sample _job


Restart the container


Docker stop $sample _job Docker rm $sample _job


If you want to completely remove the container, you need to stop the container before you can remove


Docker commit $sample _job job1


To save the state of a container as a mirror


Docker images


To view a list of all mirrors



Let's share some of the commands I use frequently:



Remove all containers and mirrors, and use one line of command to clean:


Docker kill $ (Docker ps-q); Docker RM $ (Docker ps-a-Q); Docker RMI $ (Docker images-q-a)


Just to remove all the containers, you can run the following command:


Docker kill $ (Docker ps-q); Docker RM $ (Docker ps-a-Q)


Clear a mirror with a name of none, typically to download the residue of a general failure:


Docker Ps-a | grep "exited" | awk ' {print} ' |xargs docker stop
docker ps-a | grep ' exited ' | awk ' {print '} ' |xargs Docker rm
Docker Images |grep None|awk ' {print $} ' |xargs Docker RMI


To clear a single mirror:


Docker rmi-f <image id>


Docker install asp.net core image



For Docker installation Please refer to the official website: https://www.docker.com/products/docker



Here, assuming that your Docker has been installed, the following environment is Liunx (Ubuntu 15.02).






Open https://hub.docker.com Search dotnet in the upper right corner, select the first search results microsoft/dotnet, click the following figure:






Get the order, switch to the Command line window run the following command to install the ASP.net core image.


sudo docker pull Microsoft/dotnet


What the? No response, slow speed? You're not buying a high-speed VPN.



What the? No money? You will not find a domestic Docker mirror station AH ~ daocloud mirroring ah, Aliyun Docker mirror AH. Find yourself.



After the mirror download is complete, enter sudo docker images let's check:






So far, the preparations have been completed.



Using Dockerfile Deployment



Dockerfile is what thing, dockerfile have what use, own Baidu.



Bloggers directly teach you how to write:



We can't always use port 5000, we use 60000 ports this time.



1, the program command line switch to the Publish file directory.



2, sudo touch dockerfile name do not write wrong, do not have any suffix name, to create a new Dockerfile file.



3, sudo vim dockerfile use vim to edit dockerfile. If Vim doesn't work, use gedit.



4, enter the following content:


Dockerfile
#Based on 'microsoft / dotnet: 1.0.0-core' to build our mirrors from
microsoft / dotnet: 1.0.0-core

# Copy all the files in the Project publish folder to the Publish folder in the Docker container
./publish

#Set the working directory to '/ publish' folder, that is, the container starts the default folder
Workdir / publish

#Set Docker container to expose 60,000 ports
expose 60000

#Use 'dotnet HelloWebApp.dll' to run the application

CMD ["Dotnet", "HelloWebApp.dll", "-server.urls", "http: // *: 60000"]  


Use: Wq to save and exit (Gedit ignored).



Building Mirrors



Run Docker build-t hellowebapp:1.0. To build a mirror






Running a built mirror



Use Docker run--name hellowebapp-d-P 60000:60000 hellowebapp:1.0






Open the browser to test:






The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.