Day 16/90 Docker for DevOps Engineers.
Dnyaneshwari khapekar
Expert in Linux, Networking, AWS, EC2, S3, Jenkins, Shell Scripting, Git
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.
This makes it easy to move apps between different computers or servers without worrying about compatibility issues. Docker helps developers build, ship, and run their applications smoothly, making it a popular tool for software development and deployment.
Tasks:
1. Use the docker run command to start a new container and interact with it through the command line. [Hint: docker run hello-world]
The “docker run” command is used to start a new container from an image. For example, to start a new container from the “hello-world” image and interact with it through the command line, you can run the following command:
docker run hello-world
2. Use the docker inspect command to view detailed information about a container or image.
The “docker inspect” command is used to view detailed information about a container or image. For example, to view information about a container, you can run the following command:
docker inspect Container_ID
This will return a JSON object containing various information about the container, such as its ID, name, state, network settings, and more.
3. Use the docker port command to list the port mappings for a container.
To run the chef container, you first need to have the chef image available on your local system. You can download the image by running the following command:
docker pull chef/chef
To start a new container from the “chef” image and interact with it through the command line, you can run the following command:
docker run -td --name my_chef_con -p 80:80 chef/chef
This command will run the chef container with the name “my_chef_con” in detached mode (-d), For example, map the host's port 80 to the container's port 80 (-p 80:80)
The “docker port” command is used to list the port mappings for a container. For example, to list the port mappings for a container, you can run the following command:
docker port <Container_ID>
This will return the ports that are exposed by the container and mapped to host machine ports.
领英推荐
4. Use the docker stats command to view resource usage statistics for one or more containers.
The “docker stats” command is used to view resource usage statistics for one or more containers. For example, to view statistics for a container, you can run the following command:
docker stats <Container_ID>
This will return real-time statistics for the container, including CPU usage, memory usage, and network traffic.
5. Use the docker top command to view the processes running inside a container.
The “docker top” command is used to view the processes running inside a container. For example, to view the processes running inside a container, you can run the following command:
docker top Container_ID
This will return a list of processes running inside the container, including the process ID, user, and command.
6. Use the docker save command to save an image to a tar archive and then use the docker load command to load an image from a tar archive.
To save the “jenkins/jenkins” image to a tar archive, you can run the following command:
docker save jenkins/jenkins -o jenkins.tar
To load an image from the “jenkins.tar” archive, you can run the following command:
docker load -i jenkins.tar
This will load the image from the specified tar archive file and add it to your local image repository.
Thanks... KeepLearning...