. Net Core (end) Creating a Docker image

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

Docker can be used in the operating system to separate a number of independent areas (container/container), the basic isolation between the containers, and can have their own separate system configuration, software, etc., the software between the various containers do not interfere with each other basically. Containers configured on Docker can be moved to other computers at will.
Docker is a great way to keep the applications isolated from each other, while the Docker process runs on the native operating system and does not perform as well as the virtual machine.
Docker is also better able to meet the scalability requirements of the site, can automatically expand on demand, while Docker also has "throw" features, access to the past can also reduce the number of containers.

First, install Docker
A) Learn some basic concepts first:
Image: Similar to a software installation package;
Container (Container): an instance that is running after mirroring is installed, and the same image can be used to create multiple containers on a single server;
Mirrored layer: Because the mirror can be pull, modified push, so for a mirror multiple modifications will produce multiple layers.
b) Docker's installation package is Docker.io, and after installation, use sudo docker version/info to view relevant information.

c) using Docker to analogy VirtualBox and other virtual machines, then the image is equivalent to the installation disk, "virtual machine" installed, the following load installation disk. There are various mirrors on the Docker's website, busybox This image is only about 1m. Execute the sudo docker pull BusyBox to get the image, sudo docker run-it BusyBox run, or run directly, Docker will get it automatically first. Using Linux's WhoAmI and uname-a directives, you can verify that Docker is an isolated environment. The detailed version of BusyBox is Linux f3486b919f40 4.10.0-33-generic, perhaps similar to the first version that Linus wrote in the year.
c) Adding the current user to the Docker user group eliminates the hassle of sudo before each docker instruction.

sudo groupadd Docker #确认存在docker用户组
sudo gpasswd-a zhixin Docker #将当前用户加入docker组
sudo service docker restart #重启docker服务
Finally log off and log back on to the system.


Second, Docker common commands
Docker--help
Docker run--help use a similar notation to see Help for subcommands
Exit exit container
Docker Run-it BusyBox Start a new container instance for BusyBox mirroring
Docker run-it--name <name> busybox--name Specify a name for the container
Docker PS View a running container, plus-a display Show all,-Q only displays container id,-f filter, Docker ps-a-f=ancestor=busybox Filter by name
Docker RM < container id> Delete container, use Docker RM $ (Docker ps-q-a) this You can delete all
Docker start < container id> Start a container instance, run in the background
Docker stop < container id> stop
Docker run-d BusyBox Create instances and run in the background. However, if the container does not operate, it will stop automatically, start will not stop
Docker attach < container id> start container after the default background run, attach can enter the container
Docker images list all mirrors
sudo docker rmi < mirror id> delete the mirror, remove the container for the image before deleting it

Third, make. Net Core Image
a) first get microsoft/dotnet: Runtime Mirror, this image only has the core runtime, half the microsoft/dotnet smaller.
B) Create and publish an ASP. Useurls ("http://*:5000") in Program.cs. Before the Build () method.
C) Create the Dockerfile in the Publish directory with the following content:

From Microsoft/dotnet:runtime
COPY. /publish #注意. and/between a space to copy the contents of the host's current directory to the mirrored/publish directory
Workdir/publish #设定工作目录
EXPOSE 5000/tcp #暴露 5000 Port
CMD ["Dotnet", "ForNginx.dll"]

d) Implement Docker Build-t Zhixin/web1. To build a new image
e) Perform Docker run-d-p:81:5000 zhixin/web1 to boot the mirror and map Docker's 5000 port to the host's 81 port


Learning materials: such as Peng Net. NET Accelerated http://www.rupeng.com/News/10/4603.shtml

. Net Core (end) Creating a Docker image

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.