Docker – From Scratch To App (DevOps) – Part-1
Introduction
- Docker is a platform where we can develop our application as a separate environment.
- We can run, deploy and manage our application inside a docker.
- We can create our application irrespective of the infrastructure of our system so that is a big advantage of using docker.
- Having our application independent of the infrastructure helps in the faster development of the software.
- Docker helps in faster delivery as no time is wasted around managing the correct versions of the packages.
- Testing is also done in docker.
- Overall we can conclude that docker act as a separate machine common to everyone that increases productivity and helps more in focusing on the code.
- Docker is written in Go Programming Language (the backend of Docker).
Installation
- We can directly install docker or docker desktop both work fine.
- Installation – https://docs.docker.com/get-docker/
Hello World! in Docker
- Let’s get our hands dirty with docker.
- After installation, let’s check whether it is installed correctly or not.
- So for that let’s run the following command on our terminal.
docker --version
- Currently, I am using 20.10.7, so we can see that docker is installed successfully for me.
- This is how the UI of the Docker desktop looks like.
- Now we have everything set up, so let’s first understand certain things about docker.
- Container – A container is a lightweight isolated environment where we can package and run our application.
- Many Container can be run simultaneously.
- Most of the times applications are deployed as a container.
- Image – Docker Images are the read-only instructions that are used for creating a container.
- One Image can inherit another image, likewise, multilevel hierarchy is supported.
- Hello-World image is already present in docker, so to access it, let’s run the below code.
docker run hello-world
- Here we can see that the image was not present on our local system, so it downloaded/pulled the image for us and has shown the Hello from Docker !, message.
- We are now done with the Hello World! , let’s move to some more stuff.
Common Commands used in Docker
- To see the images on your local system –
docker images
- In the output, we can see all the images are present in our local system.
- Docker images command work same as –
docker image -ls
- Both of them present the same output.
- Whenever we run an image we are creating a container, so the docker run command creates a container.
- We can run the images/containers with a different name also, for that –
docker run --name DemoName hello-world
- Here we can see that the container ran successfully.
- To see all the images that you have run-
docker ps -a
- Here we can the name of the image, container id container name as well as status and their creation time with ports.
- Similarly to see the last ran container, we can use-
docker ps -a -l
- To delete a docker image-
docker rmi -f imageName
- Here we can see in the output that we have successfully deleted hello-world image.
- We can use docker rm to delete a stopped container.
- To see all the currently running containers–
docker container ls
- To stop a container we can use-
docker stop containerId
- To forcefully stop a container we can use docker kill instead of docker stop.
docker kill containerId
- To login into someone’s organization hub or docker page–
docker login
Conclusion –
- That’s it from the first part.
- In the next part, we will learn how to create an image and what are the different tags that are used with an image.
References-
Still Curious? Visit my website to know more!
For more interesting Blogs Visit- Utkarsh Shukla Author
Other Blogs Links-
- AWS LAMBDA COLD START – https://statusneo.com/aws-lambda-cold-start/
- AWS ElastiCache with Redis Part-1 – https://statusneo.com/aws-elasticache-with-redis-part-1/
- AWS ElastiCache with Redis Part – 2 (Flask application) – https://statusneo.com/aws-elasticache-with-redis-part-2/
- Google DialogFlow Part – 1 – https://statusneo.com/google-dialogflow/
- MQTT – IoT Messaging Protocol – https://statusneo.com/mqtt-messaging-protocol/
- ElasticSearch – Using Python – https://statusneo.com/elasticsearch-using-python/
- Python Program to return vowels in a string using Decorators – https://statusneo.com/author/utkarsh-shukla/
- AWS – AppSync Introduction and Demo – https://statusneo.com/aws-appsync-introduction-and-demo/
- Python: N-Dimensional List to a 1-Dimension – https://statusneo.com/python-multidimensional-list-to-a-single-dimension/
- GraphQL Using Python – Graphene Part-1 – https://statusneo.com/graphql-using-python-graphene-part-1/
- Node-RED – https://statusneo.com/node-red/
- DECORATORS IN PYTHON – https://statusneo.com/decorators-in-python/
- OpenWhisk – https://statusneo.com/openwhisk/
0 Comments
Add Comment
You must be logged in to post a comment.