Most common used Docker Commands for SDETs

Why we need docker for selenium Tests:

Selenium grid helps to run our test cases in different operating systems and on different browsers. Usually while configuring the Selenium grid we need to host multiple virtual machines as nodes and we need to connect every single node with the hub. Also, when we set up a normal grid we need to download the Selenium server jar file and run that jar file on each computer in which we are going to set up the Selenium grid. 

This is costly and sometimes a time-consuming task for the testers. However, Docker helps us to solve cost-related and time-consuming problems.

By using Docker containers we can set up and pack a software application with all of the contents that are required to build that application, such as databases, libraries, and other dependencies, and finally, you can ship them all out as one package.

So with the help docker of we can configure the hub and nodes as images which already built in docker hub.

So since Docker is an essential tool for Automation engineer, I am sharing here the most common used docker commands.

Docker Container Commands:

Create a container (without starting it):

docker create [IMAGE]

Rename an existing container:


docker rename [CONTAINER_NAME] [NEW_CONTAINER_NAME]

Run a command in a new container:

 

docker run [IMAGE] [COMMAND]

docker run --rm [IMAGE] – removes a container after it exits.

 

docker run -td [IMAGE] – starts a container and keeps it running.

 

docker run -it [IMAGE] – starts a container, allocates a pseudo-TTY connected to the container’s stdin, and creates an interactive bash shell in the container.

 

docker run -it-rm [IMAGE] – creates, starts, and runs a command inside the container. Once it executes the command, the container is removed.

 

Delete a container (if it is not running):

 

docker rm [CONTAINER]

Update the configuration of one or more containers:

 

docker update [CONTAINER]

Starting and Stopping Containers:

Start a container:

 

docker start [CONTAINER]

Stop a running container:

 

docker stop [CONTAINER]

Stop a running container and start it up again:

 

docker restart [CONTAINER]

Pause processes in a running container:

 

docker pause [CONTAINER]

Unpause processes in a running container:

 

docker unpause [CONTAINER]

Block a container until others stop (after which it prints their exit codes):

 

docker wait [CONTAINER]

Kill a container by sending a SIGKILL to a running container:

 

docker kill [CONTAINER]

Attach local standard input, output, and error streams to a running container:

 

docker attach [CONTAINER]

 

Docker Image Commands:

 

Create an image from a Dockerfile:

 

docker build [URL]

docker build -t – builds an image from a Dockerfile in the current directory and tags the image

 

Pull an image from a registry:

 

docker pull [IMAGE]

Push an image to a registry:

 

docker push [IMAGE]

Create an image from a tarball:

 

docker import [URL/FILE]

Create an image from a container:

 

docker commit [CONTAINER] [NEW_IMAGE_NAME]

Remove an image:

 

docker rmi [IMAGE]

Load an image from a tar archive or stdin:

 

docker load [TAR_FILE/STDIN_FILE]

Save an image to a tar archive, streamed to STDOUT with all parent layers, tags, and versions:

 

docker save [IMAGE] > [TAR_FILE]

Docker Commands for Container and Image Information

 

List running containers:

docker ps

docker ps -a – lists both running containers and ones that have stopped

List the logs from a running container:

docker logs [CONTAINER]

List low-level information on Docker objects:

 

docker inspect [OBJECT_NAME/ID]

List real-time events from a container:

 

docker events [CONTAINER]

Show port (or specific) mapping for a container:

 

docker port [CONTAINER]

Show running processes in a container:

 

docker top [CONTAINER]

Show live resource usage statistics of containers:

 

docker stats [CONTAINER]

Show changes to files (or directories) on a filesystem:

 

docker diff [CONTAINER]

List all images that are locally stored with the docker engine:

 

docke image ls

Show the history of an image:

 

docker history [IMAGE]

Networks

 

List networks:

One of the most valuable features of Docker software is the ability to connect containers to each other and to other non-Docker workloads. This section covers network-related commands.

 

docker network ls

Remove one or more networks:

 

docker network rm [NETWORK]

Show information on one or more networks:

 

docker network inspect [NETWORK]

Connects a container to a network:

 

docker network connect [NETWORK] [CONTAINER]

Disconnect a container from a network:

 

docker network disconnect [NETWORK] [CONTAINER]

That's all the commands we need for docker. Hope this is useful.

Comments

Post a Comment

Popular Posts

Linux commands 1 : Commonly used FILE AND DIRECTORY COMMANDS for daily use and interview

Running tests from maven command line: Different options