Docker deployment. Net core 3.1 (Chapter 2)


The previous chapter described how to install docker and pull images【 】The basic environment has been set up. Here is how to deploy the. Net core project

1. Create a new. Net core project (version 3.1 is used here). This function can run and access it








2. Publish the project and upload it to Linux_ A this path is self built]


3. Pull the image of. Net core3.1: docker pull : 3.1 [this process is relatively slow and patient]



After pulling, enter docker images to view all images. The red box below shows success

4. Create a dockerfile named file. Do not have a suffix. Put it in / Smile / smile_ A under the path of [your own project path], this file has the following contents:

    FROM :3.1【 : 3.1 the image name is the name in the red box in point 3]
    RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
    WORKDIR /app
    COPY . .
    ENTRYPOINT [“dotnet”, ” SmileLinuxPush.dll “]【 SmileLinuxPush.dll Is the DLL name of your project]


5. Input: CD / Smile / smile_ a  



6. Create image: docker build – t netcore-smile-c



After success, enter docker images to view the image



7. Generate container, visit the website: docker run — name smile-c — restart = always – P 5100:5100 – D netcore-smile-c
Smile-c: Custom container name
Netcore-smile-c: image generated by current project [point 6]

— restart = always: when docker restarts, the container starts automatically
5100:5100: indicates the mapping between external port and internal container port [external port, point 1]

8. View all containers: docker PS – A


Visit http://:5100