Docker practice of asp.net core

If the docker and .net core images are not installed in centos, first install the docker and asp.net core images

安装docker
yum -y install docker-io

Start the Docker background service
service docker start

Pull asp.net core image
docker pull microsoft/dotnet

publish dotnet publish

Add the Dockerfile file in the publish folder

FROM docker.io/microsoft/dotnet

COPY . /app

WORKDIR /app

EXPOSE 8004/tcp

ENTRYPOINT ["dotnet", "CentOSWebApp.dll"]

Copy the publish folder to the CentOS system
, enter the published directory and run the following build command to build the Docker image.
docker build -t my_first_docker_app .
Note the . at the end of the command to specify the context path. In this command, the context path is .

run the container

docker run -d -p 8005:8005 my_first_docker_app

The -d parameter is also running in the background, and then you can see the running status of the container through docker ps, and stop it through docker stop container id.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324582104&siteId=291194637