- Docker - Working of Kubernetes
- Docker - Kubernetes Architecture
- Docker - Continuous Integration
- Docker - Compose
- Docker - Logging
- Docker - Cloud
- Docker - Setting ASP.Net
- Docker - Toolbox
- Docker - Setting NGINX
- Docker - Setting MongoDB
- Docker - Setting Node.js
- Docker - Networking
- Docker - Storage
- Docker - Container Linking
- Docker - Instruction Commands
- Building a Web Server Docker File
- Docker - Private Registries
- Docker - Managing Ports
- Docker - Public Repositories
- Docker - Building Files
- Docker - File
- Docker - Containers & Shells
- Docker - Configuring
- Docker - Container & Hosts
- Docker - Architecture
- Docker - Working With Containers
- Docker - Containers
- Docker - Images
- Docker - Hub
- Docker - Installation
- Docker - Installing Docker on Linux
- Docker - Overview
- Docker - Home
Docker Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Docker - Containers
Containers are instances of Docker images that can be run using the Docker run command. The basic purpose of Docker is to run containers. Let’s discuss how to work with containers.
Running a Container
Running of containers is managed with the Docker run command. To run a container in an interactive mode, first launch the Docker container.
sudo docker run –it centos /bin/bash
Then hit Crtl+p and you will return to your OS shell.
You will then be running in the instance of the CentOS system on the Ubuntu server.
Listing of Containers
One can pst all of the containers on the machine via the docker ps command. This command is used to return the currently running containers.
docker ps
Syntax
docker ps
Options
None
Return Value
The output will show the currently running containers.
Example
sudo docker ps
Output
When we run the above command, it will produce the following result −
Let’s see some more variations of the docker ps command.
docker ps -a
This command is used to pst all of the containers on the system
Syntax
docker ps -a
Options
─a − It tells the docker ps command to pst all of the containers on the system.
Return Value
The output will show all containers.
Example
sudo docker ps -a
Output
When we run the above command, it will produce the following result −
docker history
With this command, you can see all the commands that were run with an image via a container.
Syntax
docker history ImageID
Options
ImageID − This is the Image ID for which you want to see all the commands that were run against it.
Return Value
The output will show all the commands run against that image.
Example
sudo docker history centos
The above command will show all the commands that were run against the centos image.
Output
When we run the above command, it will produce the following result −
Advertisements