Sunday, October 17, 2021

Basic Docker Commands

 Trying to list some Docker commands:

1. docker run 

Run a container from an image

2. docker run nginx

Will run an instance of the nginx application on the docker host.

3. docker ps

Lists all running containers

4. docker ps -a

Will list all containers (running, stopped and exited ones)

5. docker stop <id or name>

Stops a container

6. docker rm <id or name>

Remove stopped or exited containers

7. docker images

List of images on the host

8. docker rmi <image name>

To remove an image.

9. docker pull <imagename>

Pulls an image. Logically if the image is not present and if we run a `docker run` command, it will pull the image if not found locally. This takes time and we can pull and keep an image locally if needed.

10. docker run <repository name>

Runs in the foreground

11. docker run -d <repository name>

Runs in the background.

12. docker attach <container ID>

This is used to attach to a container running in the background. To get the ID, use the `docker ps` command.



No comments:

Post a Comment