How To Create Container In Docker-CE On CentOS 7

How To Create a Container using commands and inspect the docker container image. You can also list all the docker containers using an image. I have already downloaded two Apache images from Docker hub as shown in the figure below.

you can also download an image from Docker hub and make your own by Dockerfile in the Linux machine. you can also pull the CentOS image then install the apache server inside them and other required packages. 

How To Create Container In Docker:

We can create a new docker container either using docker container commands or from the image as well as using the dockerfile.

If you have a custom image ready, So just pull it from the docker hub and start using it to create the container.

Check Out: How To Remove Docker Image, Volumes & Container In Linux

docker pull image_name

Apache Images Download, To list all images, use docker images

How To Create Container

Check Out: How To Uninstall Docker CE

I have created a container using Apache 2.4 image from docker hub & login with bash.

docker run -it --name apachecon e40405f80704 /bin/bash

Apache ID = e40405f80704

Container name = apachecon

Shell= /bin/bash

docker list containers


you can also send the container in the background. So you will enter the container shell.

docker run -itd --name apachecon e40405f80704 /bin/bash

Now apache container has been created and you can see Apache configuration files here.

docker container inspect

Check Out: How To Change Docker Container Name Using Command In Linux

Note: if you want to come out from the container, use ctrl+p+q, do not use the exit command otherwise the container would be stopped. you will have to start it again. 

If you want to see the running container,

docker ps

docker container commands

Check Out: Create Apache Docker Image Using Dockerfile In Linux

If you want to enter the container, you can use below command,

docker attach apachecon

Now you can do your work here,

YouTube Link: Create a Docker Container

You’re done docker container commands docker container inspect docker list containers

Share on:

I'm the founder of Curious Viral. I hope this blog will provide you complete information about Linux Technology & I would like to share my technical knowledge with you which I have learned during this period.

Other Posts You May Like...

Leave a comment