Docker
In this article, I have shared some basic commands in Docker. For developing, running and many more operations, Docker is an open-source platform. This will help you to get information containers that are running currently and also stopped containers.
Why do we use Docker in DevOps?
ans: In DevOps, containers help to give features like build, test, deploy, and many more pipelines.
docker run -it ubuntu
How to check when ubuntu started?
docker ps
How to check that all the images are downloaded to my local machine?
docker images
How to download ubuntu?
docker run -it ubuntu
How to show all containers?
docker container ls
How to go inside a running container?
Note: bash shell should be attached to this running container.
This command will not work if your container isn't running.
command: docker container exec -it CONTAINER_ID
1st pic shows one container is already running:
2nd pic shows now we are in same container:
docker run mongo
how to see all running and stopped containers?
command: docker ps -a
how to stop the container?
docker stop container_id
How to show all information regarding the container?
docker inspect CONTAINER_ID
How to check all logs?
docker logs container_id
docker container prune -f
How to run a container in the background?
docker run -d CONTAINER_NAME
Note: In the background, docker can run the container, and -d means detached mode.
docker run ubuntu echo "Hello World"
docker logs container_id
docker logs --since time container_id
docker logs --since 5s a3c5
It will show the last 5 second's logs
How to install Nginx?
docker run nginx
docker run -d -p 8087:80 nginx
Note: this nginx is running on my local system right now.
How to share a container?
first, make some changes and then keep its container id. then exit and then run :
docker commit -m "message" container_id new_given_name
suppose I have given name names_ubuntu
docker commit -m "added names.txt file" 388dd2f309a8 names_ubuntu
Note: keep its id.
STEPS:
1.
Note:
all images you can find here: Docker Hub
Comments
Post a Comment