Docker is an open-source technology where it is used for deploying applications through containers and it is currently the most well-known container platform. The Docker Containers are filled with running images and they can be created when running an image. Images serve as a starting point for the building of containers. They give details on what’s needed to build containers. Images can be kept on-site or in the cloud.
In this article, you will be able to learn how to start a Docker container on your Linux based VPS. Before starting the guide, note that you will need to access your VPS with a SSH and the sudo privilege.
Step 1: Listing Docker Images
Firstly, we will need to list out the docker images by using the following command in your terminal.
sudo docker images
To display more information regarding the images, run the following command.
sudo docker images --help
If you do not have a Docker image yet, you will need to pull an image by going to the Docker hub, then pull an image. You may browse every image page for more detailed information regarding the image. To pull the image, use the following command.
docker pull <image_name>
Replace the “<image_name>” with any image name of your choice that you had found in Docker Hub.
Step 2: Create Container
Next, we will create a container from the image by running the image. To create the Docker container, use the following command below.
docker run <image_name>
Similar to step 1, replace the “<image_name>” of your own preference. With this, your container will be created.
Step 3: Start Container
Your container has not started despite only being created. To start the container, use the following command.
docker run --name <container_name> -it <image_name> bash
Replace “<container_name>” with any name of your preference. Open another terminal with SSH and run the following command.
sudo docker ps -a
You should be able to see your container is now running. With this, you have completed starting your container. Here are some extra options you may run for your container. To stop your container, use the following command.
sudo docker stop <container_name>
To view the top process of the container, run this.
sudo docker top <container_name>
To monitor the container, run the following command.
Finally, to kill your Docker container, run this command.
sudo docker kill <container_name>