Docker run Container and get inside it

Continuing to our series Docker for Beginners, In the previous post we’ve seen What is Docker and its related terminologies, How one can get started with Docker. In this post we will be seeing how to pull existing docker image run container and get inside the same.

So, let’s started.

First we will see how to run a Docker Container, Here we will run hello-world container, Let us understand what it will do,

docker container run hello-world

Docker Architecture Diagram
Docker Architecture

When we do Docker container run hello-world, it will look for the image locally, when it finds the image is not available locally which is docker host it downloads from the registry or server.

Whatever you see on your terminal is your docker client, docker host is installed on your system when you install docker.

So when we run above command we get below ouput.

Run docker container
Run docker container

Similarly let’s run redis container inside our docker but here we will run container in detach mode, that is it won’t stick to terminal.

docker container run -d detach

Your container is up and running and you get container id.

Now check the container is really running or not.

docker container ls

Now we will see to get inside the running container and how to start container in interactive mode.

To start a container in interactive mode.

docker container run -it ubuntu

interactive mode
interactive mode

you can get inside the container.

Now we will see how to get inside running container,

Run the redis container in detach mode.

docker container run -d redis

This will run the container in detach mode, now check the container with,

docker container ls

Now use below command to get inside the running redis container.

docker exec -it <container|_id/name>bash

Heavy breathing that’s lot of command to get started, But 1 milestone is achieved. Let me know if you have any queries.



Categories: DevOps, Docker

Tags: , , , , , ,

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: