[Docker] learning notes -- building gitlab and dockergitlab
Gitlab is an open-source project used for warehouse management systems. A web service built on Git as a code management tool.
Detailed introduction can refer to the official website, https://about.gitlab.com/
Today, we mainly build a Gitlab environment on docker to explain the docker commands used.
:
Basic knowledge addition: understand the concepts of image and container in docker. image can be understood as VM template, and container can be understood as the VM generated from VM template.
The container is generated from the image using the docker run Command.
For how to install docker, see the https://docs.docker.com/installation/
Note: All the following commands can be found inHereFind the detailed description. If it is not a root user, add sudo to docker.
1. docker search gitlab
Search for images with gitlab keywords on docker hub/public registry. The higher the stars value, the better the image.
Note: You can also directly enter gitlab on index.doc ker. io to search, and then click sameersbn/gitlab. after entering the webpage, refer to readme for operations.
2. docker pull sameersbn/gitlab: latest
Download the image from docker hub to the local machine. sameersbn/gitlab is the image name and latest is the tag. If no tag is written, the default value is latest.
Note: We can also download the latest dockerfile from github without directly using the pull image, and then build it using the following command.
Docker build-t "lemonbar/gitlab". // note that the "." here is not a full stop. It represents the path of dockerfile and the current path. -T is the name of the built image.
Docker push lemonbar/gitlab // you can use the push command to upload your image to the public registry.
3. docker images
Check which docker images already exist locally. After docker is installed, it is empty by default.
4. mkdir-p/opt/gitlab/data & mkdir-p/opt/gitlab/mysql
Before proceeding, we will create two folder to store some files that will be running in gitlab container.
Benefit: After the iner is stopped or deleted, some of the files we store will not be deleted with the container.
5. docker run -- name = gitlab-P-d-v/opt/gitlab/data:/home/git/data-v/opt/gitlab/mysql: /var/lib/mysql sameersbn/gitlab
Generate the container named gitlab from the image sameersbn/gitlab.
-- Name is the name of the newly generated iner.
-D: run the container in the background. You can also use-I to run the container interactively. You can see the output or enter
-V maps the volumn In the iner to the Host Storage./opt/gitlab/data is the host path, And/home/git/data is the path in the container.
-P (uppercase) is an important parameter. It is used to map all the ports in the iner to the random ports on the host, in this way, machines in the same network as the host can access the container.
If you do not want to map all ports in the iner, you can use-p (lower case) for separate ing.
This command is the most important of all commands! (None)
6. docker ps-
Check the containers on the host and the main information of each container.
7. docker inspect gitlab
It can be used to view the detailed information of the container. gitlab is the name of the container, or you can enter the id of the container (the id does not need to be fully input, as long as the first few digits can uniquely identify this container)
8. docker stop gitlab
Used to stop the gitiner named gitlab
9. docker rm gitlab
Used to delete the gitiner named gitlab
10. docker rmi sameersbn/gitlab
Used to delete an image named sameersbn/gitlab
First, you can master the preceding commands when using docker. If you have any questions, please refer to https://docs.docker.com/reference/commandline/cli/
If you don't want to install docker on your machine, just want to have a simple understanding of docker commands, you can visit the following website for exercises.
Https://www.docker.com/tryit/
Write this article today. The next article will introduce how to build and use your own docker registry.