For the basic knowledge and theory of docker, please move to Baidu. This article will not introduce much, mainly on practical skills, how to build your own image
1: Create a Dockerfile
Dockerfile is a text file used to build an image. The text content contains instructions and instructions for building an image.
Create a mirrored folder: mkdir dockerfiles
Enter the folder and upload the gatway.jar package to this directory, preferably in the same directory as the Dockerfile
Common parameters:
The FROM : Specifies group basis mirror, must as a first command
LABEL : Maintainer information
RUN : The command executed when building the image
COPY : Add local files to the container
CMD : The command called when the container starts .
EXPOSE : Expose the specified port, which is used to open the specified port to be monitored for the container to communicate with the outside world
2: Create a mirror
docker build -t name: version number. The latter point needs to be noted, which means to retrieve the Dockerfile file from the current folder
View the mirror docker images and docker image ls just built
3: start the container
docker run -d --name gatwayimg_1.0 -p 8888:8888 gatwayimg_1.0
-d<Background running> --name <specified container name> -p<host port: internal port> gatwayimg_1.0<image name>
View specific container logs : docker logs -f gatwayimg_1.0
4: Other commonly used commands
To check if the jar is started successfully , you can check the port:
Check the list of nacos services and find that the service is registered
Enter the container : docker exec -it gatwayimg_1.0 /bin/bash, which is actually a linux environment
View all containers : docker ps -a
Stop the container : docker stop gatwayimg_1.0
Delete the container : docker rm -f gatwayimg_1.0
Delete the image : docker rmi -f gatwayimg_1.0