Day 18 : Docker for DevOps Engineers
Docker Compose:
Docker Compose is a tool that was developed to help define and share multi-container applications.
With Compose, we can create a YAML file to define the services and with a single command, can spin everything up or tear it all down.
What is YAML?
YAML is a human-readable data serialization language used for configuration files and data exchange. It's not a markup language but is designed for representing structured data in a simple and readable format.
YAML files use a .yml or .yaml extension.
How to run Docker commands without sudo?
Make sure docker is installed and system is updated (This is already been completed as a part of previous tasks):
sudo usermod -a -G docker $USER
Reboot the machine.
Task-1:
Docker-compose:
- Install Docker Compose if not already done.
Create a new project directory.
Create a YAML file (usually named
docker-compose.yml
) in the project directory.
- Use
docker-compose up
to start your services based on the YAML file.
Task-2:
- Pull a pre-existing Docker image from a public repository (e.g. Docker Hub) and run it on your local machine. Run the container as a non-root user (Hint- Use
usermod
command to give user permission to docker). Make sure you reboot instance after giving permission to user.
Inspect the container's running processes and exposed ports using the docker inspect command.
To inspect a container's running processes and exposed ports using the
docker inspect
command, you can follow these steps:
- Use the docker logs command to view the container's log output.
To view a container's log output using the docker logs
command, simply run the following command:
- Use the docker stop and docker start commands to stop and start the container.
To stop a container:
docker stop CONTAINER_ID_OR_NAME
To start a container:
docker start CONTAINER_ID_OR_NAME
- Use the docker rm command to remove the container when you're done.
To remove a Docker container when you're done with it, use the following command:
Before removing container , one needs to stop that container.
Thank you for reading :-)
Priyanka varshney
Subscribe to my newsletter
Read articles from priyanka varshney directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
priyanka varshney
priyanka varshney
๐ Hello, and welcome to my DevOps journey! ๐ I am Priyanka Varshney,๐ ๏ธ As an aspiring DevOps engineer, I'm all about bridging the gap between development and operations, making software delivery seamless and efficient. ๐ป๐ง On this Hashnode blog, I'll be sharing my learnings, experiences and adventures as I dive deep into the world of continuous integration, automation, and cloud technologies. โ๏ธโ๏ธ Let's connect, learn, and grow as a vibrant DevOps community. Follow my Hashnode blog, and let's embrace the DevOps adventure together! ๐ค๐