While learning Docker, many commands came out, so I will output them.
The name of the registry where Docker image is managed (like Git Hub).
There are other registries that manage Docker images, one of which is the Docker Hub
.
Like Git Hub, Docker Hub can be managed in the repository. You can easily set up a development environment by sharing the repository (image) with various people such as teams. An image of cloning a remote repository locally in GitHub.
Make a new registration from Website of Docker Hub. Open a terminal and log in.
$ docker login
Login Succeeded
Is displayed, login is successful.
Pull the repository managed by Docker Hub locally.
$ docker pull <image name>
For example, if testOS
is the repository name
$ docker pull WindowsOS
This completes the repository clone locally.
Run the run
command to work in the container that contains the Windows OS.
$ docker run -it testOS bash
Now you can create a container and go inside it. Here, we will organize the information in the next part.
I just pulled a repository (image) called testOS
locally from Docker Hub.
However, at this point you cannot use testOS in your local environment.
For example, testOS is required in the development environment of the application to be created, so we want to be able to use testOS. Therefore, you can use testOS by creating a container that contains testOS and working in that container.
$ exit
You can exit the container with this command.
$ docker ps -a
If you don't add -a
, only moving containers will be displayed, so you need -a
to display all.
$ docker images
If you exit the container with the exit
command after run
, the container will be in the exited
state.
As it is, the container has not started and you cannot enter it, so start it again.
$ docker restart
Then, with the exec
command, type the command to enter the container again.
$ docker exec -it <name of container> bash
Suppose you need Ruby, PHP, or Javascript in your development environment. One person has set up to handle Ruby, PHP, Javascript in the container.
It takes time and effort for other people to build the same environment. → Save the working environment of the container set by one person in the image (repository) and provide it to solve the problem!
$ docker commit <container> <image>
This command saves the changes in the container to image.
Create a new repository with Docker Hub in advance. (Here, new-repo) The names must match, so tag them.
$ docker tag old-repo:updated username/new-repo
updated in the local repository where old-repo made changes, with tags representing updates. Match the name with username / new-repo to the newly created "new-repo" in Docker Hub.
$ docker push username/new-repo
This completes the push to the repository managed by Docker Hub By pulling, you can handle the modified image (repository) locally.
$ docker rmi <image>
Recommended Posts