Write it at the front
As an open source application container engine, docker can make it easy for us to build a lightweight and portable container. Continuous delivery, testing and deployment through docker are extremely convenient. Moreover, for our development, the most intuitive advantage is to solve various difficulties caused by the differences between the environment configuration and the deployment environment configuration in daily development Miscellaneous diseases, since then, the wording of the product is less – “my computer is normal!”. In short, docker is accompanied by the existence of the “true fragrance theorem”.
Taking the installation of Ubuntu subsystem under Windows 10 as an example
1. 1 install Ubuntu in Microsoft app store
1.2 start and set password
In addition, if you want to install the image interface, you can do it by yourself Baidu. You don’t need to install it here. The real men are all directly on the command line.
Install docker under Ubuntu
Command summary:
//https://www.cnblogs.com/EminemJK/p/13188444.htmlsudo apt-get remove docker docker-engine docker-ce docker.io
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
apt-cache madison docker-ce
sudo apt-get install docker-ce
sudo service docker start
2.1 remove the official old docker version of APT
sudo apt-get remove docker docker-engine docker-ce docker.io
2.2 update apt
sudo apt-get update
2.3 configure apt to pull image through HTTPS
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
2.4 setting the official GPG key of docker
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
2.5 add stable repository
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
2.6 installing docker CE Community Edition
sudo apt-get install docker-ce
2.7 start docker
sudo service docker start
Is 2.8 over? Not yet. Check the docker running status
sudo service docker status
Then use the following command to view the docker version. You will find that there is only client and no server. So this is the particularity of the subsystem under windows. Additional download requiredDocker for windowsAs the server of docker.
docker version
2.9 install and run docker for windows
After installation, the computer will restart automaticallySo remember to save the code you write after staying up late. After restart, set it again.
2.9.1 configure and refresh environment variables
echo "export DOCKER_HOST='tcp://0.0.0.0:2375'" >> ~/.bashrc
source ~/.bashrc
Why is this port 2375? Check the configuration of docker for windows above and check the version again
Finally, docker is installed.
Launch blazor
3.0 because docker is not supported by blade webassembly app, a new blade server project is created
3.1 add docker file
3.2 select Linux and modify the dockerfile file
#Using runtime mirroring
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
#Set working directory
WORKDIR /app
#Copy the contents of the directory to the current directory
COPY . .
#Run the image entry command and the executable name
ENTRYPOINT ["dotnet", "BlazorApp.dll"]
3.3 release (this process is a bit long)
Publish to docker
In the windows 10 subsystem, we don’t need to copy the files to the Linux system like an independent Linux. If we check the disk situation through the following command, we will find that it has been mounted for us, and there is no need to copy and copy the published files, which is really delicious.
df -h
4.1 direct CD into release path
4.2 building image
docker build -t blazorapp .
Note that you can’t use uppercase. You must name it in lowercase and have a [.] at the end
4.3 creating containers
docker run -d -p 8072:80 blazorapp
Description: the container exposes port 80, and specifies the host 8072 port to communicate with it (host port: container exposed port).
4.4 view current image
docker image ls
Please ignore nginx. I installed it later.
Publishing complete
Docker publish to private warehouse
Publish to a private warehouse. Here we use docker hub as an example. First, register an account on the docker hub, and then push.
6.1 marking
docker tag blazorapp liohuang/blazorapp
If you do not log in, you will be prompted to log in to your account first.
6.2 push to warehouse
docker push liohuang/blazorapp
The next time you use the pull command, you can pull it.
This article has authorized exclusive authorization for the DotNetGeek (ID:dotNetGeek) official account.