Playing with docker

Today I got some free time to play with Containers and docker on RHEL7, below are some of my notes that I found useful…….

Step 1 Install Docker on RHEL 7

# subscription-manager repos --enable rhel-7-server-extras-rpms
# subscription-manager repos --enable=rhel-7-server-optional-rpms
# yum install docker
# yum install device-mapper-libs device-mapper-event-libs
# systemctl disable firewalld
# systemctl stop firewalld
# systemctl start docker
# systemctl enable docker
# systemctl status docker

Step 2 get an Image:

To get Docker images from a remote registry and add them to your local system, use the docker pull command:

# docker pull <registry>[:<port>]/[<namespace>/]<name>:<tag>

To see the images on your system, type docker images

# docker images

Inspect an image: Run docker inspect

# docker inspect <full/name/of/image>

To remove images you no longer need, use the docker rmi command:

# docker rmi <image name>

If you want to clear out all your images, you could use a command like the following

# docker rmi $(docker images -a -q)


Step 3 run a Container:

When you execute a run command, you essentially create a new container from a Docker image. That container consists of the contents of the image, plus additional options you pass on the docker run command line.

docker run \
-d \
--name <name> \
--network=host \
-e TZ="<timezone>" \
-e option="<optioin>" \
-v <path/to/config>:/config \
-v <path/to/temp>:/temp \
-v <path/to/data>:/data \

List running containers:

# docker ps

Stop a container:

# docker stop myrhel_httpd

Restart a container:

# docker start myrhel_httpd

To remove containers you no longer need, use the docker rm command

# docker rm <name>

To see a list of containers that are still hanging around your system, run the docker ps -a

Other usefull stuff:

Shell access to the container while it is running:

docker exec -it <name> /bin/bash

See the logs given by the startup script in real time:

docker logs -f <name>

More Info:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your 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