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.
docker pull image_name
Apache Images Download, To list all images, use docker images
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
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.
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,
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