#Day 16 Docker Basics.

#Day 16 Docker Basics.

Β·

4 min read

Docker

Docker is a software platform that allows you to build, test, and deploy applications quickly. Docker packages software into standardized units called containers that have everything the software needs to run including libraries, system tools, code, and runtime. Using Docker, you can quickly deploy and scale applications into any environment and know your code will run.

In simple words,

Docker is a tool that makes it super easy to create, deploy, and run applications using containers. 🐳

Now, what's a container, you ask? πŸ€”

Think of a container like a virtual box πŸ“¦ for your software. It includes everything your app needs to run: code, runtime, libraries, and dependencies. Just like how you pack all your stuff for a trip into a suitcase, Docker packs everything your app needs into a container. 🧳

Why is this cool? 🌟

Well, containers are super lightweight and portable. They run the same way on any machine, whether it's your laptop, a server in the cloud, or even your friend's computer. 🌐 No more "It works on my machine" excuses! πŸ˜‰

Plus, Docker makes it easy to share your containers with others. You can send them to your teammates, upload them to the cloud, or even publish them for the whole world to use. πŸš€

So, in a nutshell, Docker is like a magic box that holds all the ingredients for your app, makes it easy to run anywhere, and lets you share it with others.

Docker commands.

  • docker run

Helps to run the new container.

Let's create a container for MySQL.

We don't have any running containers right now. Let's run the container for mysql5.7

We need to set the environment 1 variable for the container as given. and we will run the container in detached mode.

Container running with MySQL database, let's interact with it.

[Note - dont' forgot to give a tag to your application i.e MySQL:5.7:latest

  • docker exec

This command helps you to interact with the application running inside the container.

To use the MySQL inside the container we need to run the below command

docker exec -it <container ID> bash (then login with ID PWand access the application)

exit command will help to exit from application and container

  • docker inspect.

is a command-line tool used to obtain detailed information about Docker objects like containers, images, networks, and volumes. It provides JSON-formatted data containing various attributes and configurations of the specified Docker object, such as its ID, name, network settings, mounts, and more. This information can be useful for troubleshooting, debugging, or understanding the characteristics of Docker resources.

docker inspect <container id>

  • docker port

command is used to list the public-facing ports of a container. It shows the mapping between the ports inside the container and the corresponding ports on the Docker host. This command helps you to see which ports of the container are accessible from outside.

  • docker stats

command provides real-time monitoring of resource usage for all active Docker containers. It displays information such as CPU usage, memory usage, network I/O, and disk I/O for each container. This command is useful for monitoring the performance of containers and diagnosing resource-related issues. When executed without any additional options, it continuously updates the statistics until you interrupt it.

  • docker top

command is used to display the running processes of a Docker container. It provides a list of processes running inside the specified container, along with information such as the process ID (PID), user, CPU usage, memory usage, and command being executed. This command is useful for troubleshooting and monitoring the processes running within a container.

  • docker save

command is used to save Docker images to a tar archive file. This command is useful when you want to export Docker images from your local Docker environment to be imported into another Docker environment, such as on a different machine or in an air-gapped environment without direct internet access.

docker save [OPTIONS] IMAGE [IMAGE...]

  • docker load

command is used to load Docker images from a tar archive file created by the docker save command. This command is typically used when you want to import Docker images into a Docker environment from an archive file, either from your local machine or from another source.


Thank you for joining me on this journey into DevOps! Your curiosity is the driving force behind this exploration. If you found value in these insights, I'm thrilled! Keep the DevOps flame alive, and stay tuned for more exciting adventures in the world of technology. Happy Learning! πŸš€βœ¨"

"Closing the gap between usβ€”let's connect and make our virtual bond stronger on social media!

Click on -Umesh Salunkhe

Β