Table of contents
๐ 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.
๐ Tasks
๐ Use the docker run
command to start a new container and interact with it through the command line. [Hint: docker run Hello-Dosto]
๐ถ The docker run
command is used to create and start a new Docker container from a specified image. It allows you to customize various aspects of the container, such as its name, network settings, environment variables, and more. Here is an overview of the most commonly used options and features of the docker run
command:
๐ทTo run the application use:
docker run java-app
๐ Use the docker inspect
command to view detailed information about a container or image.
๐ท The docker inspect
command is used to retrieve detailed information about Docker objects, such as containers, images, volumes, networks, and more. It provides a JSON representation of the object's configuration, status, and metadata.
๐ถ To inspect the container.
docker inspect <container_Id>
๐ Use the docker port
command to list the port mappings for a container.
๐ทThe docker port
command allows you to view the public ports that are mapped to a running Docker container. It provides information about which ports on the host system are forwarded to the container's exposed ports. This is useful for inspecting the port mappings, especially when multiple containers are running, and you need to know how to access a specific container's services.
docker port <container_Id>
๐ Use the docker stats
command to view resource usage statistics for one or more containers.
๐ทThe docker stats
command is used to display a real-time stream of resource usage statistics for running Docker containers. This command provides information on CPU, memory, network I/O, and block I/O usage for each container. It's a helpful tool for monitoring and managing container resource usage.
docker stats <container_Id>
๐ Use the docker top
command to view the processes running inside a container.
๐ทThe docker top
command is used to view the running processes within a Docker container. It provides a list of processes running inside the specified container, along with details such as the process ID (PID), user, CPU usage, and more. This command can be helpful for troubleshooting and monitoring the processes within a container.
๐ถHere's the basic syntax of the docker top
command:
docker top <container_Id>
๐ Use the docker save
command to save an image to a tar archive.
๐ทThe docker save
command is used to save one or more Docker images as tarball archive files. This is particularly useful when you want to export Docker images from your local system, for example, to move them to another machine or share them with others.
๐ถ The saved image can be imported into another Docker environment using the docker load
command.
docker save <container_Id>
๐ Use the docker load
command to load an image from a tar archive.
๐ทThe docker load
command is used to import Docker images that have been saved as tarball archive files using the docker save
command. It allows you to load these images into your local Docker environment. This is useful when you need to transfer Docker images between systems, share images with others, or simply bring images back into your local Docker repository.
docker load