Tuesday 12 March 2024

Docker Container Commands for a DevOps Engineer



 
 Docker Container Commands for a DevOps Engineer

The below illustration shows some common container commands and their syntax 

1.  Creates a container from an image

docker run -it --name nginx nginx

2.  Begins a Docker container

docker start nginx

3.  Restarts a Docker container.

docker restart nginx

4.  Temporarily halts a container.

docker pause nginx

5.  Resumes a paused container.

docker unpause nginx

6.  Ends a running Docker container.

docker stop nginx

7.  Forcefully stops a running container

docker kill nginx

8.  Lists Docker containers.

docker ps

9.  Accesses a container's shell.

docker exec -it nginx /bin/bash

10.  Connects to a running container.

docker attach nginx

11.  Views container logs.

docker logs nginx

12.  Change a container's name.

docker rename old-name new-name

13.  Retrieves container info.

docker inspect nginx

14.  Copies files to/from a container.

docker cp nginx:/container-path/file.txt /local-path

15.  Deletes a container.

docker rm nginx

These container commands are essential for managing containerized applications, whether for development, testing, or production deployment, as they enable efficient control and manipulation of container instances.

Labels:

0 Comments:

Post a Comment

Note: only a member of this blog may post a comment.

<< Home