The purpose of Docker is to make it easier to create, deploy, and run applications using containers. Containers allow the developer to package an application with all the necessary parts (libraries and other related resources) and deliver it as a single package.
Thanks to Containers, the developer is certain that the application will run on any Linux machine, regardless of any customization of the settings of that same machine. In fact, without Containers, if the settings of the machine hosting the Container are different from the settings of the machine that was used for writing the application (or for testing the code), compatibility issues may occur.
If you are not familiar with containers and you want to know more about it, read our blog post: Containerization explained: run your code on any infrastructure.
Below you can find some guidelines on how to install Docker on your machine, according to the OS you are using.
For Linux users there are 3 different alternatives to install Docker:
- Tutorial for those who have never used Docker;
- Generic script provided by docker:
curl -sSL https://get.docker.com/ | sh;
- For those who want to follow the specific instructions on their operating system.
If you have a MacOS machine, follow the steps below:
- Download and Install Docker Community Edition;
- Once installed, click on the icon and start the app:
docker run hello-world.
If you are using Windows, you will need to install Docker Desktop. Please refer to the official Docker documentation.
Basic Commands - Life Cycle
docker createcreates a container but does not start it.
docker renameallows you to rename the container.
docker runcreates and starts a container in one operation.
docker rmdeletes a container.
docker updateupdates the resource limits of a container.
Start and Stop
docker startstarts a container so that it is running.
docker stopstops a running container.
docker restartstops and starts a container.
docker pausepauses a working container, "freezing it" instead.
docker unpausereactivates a paused container.
docker waitblocks until the container stops.
docker killsends a SIGKILL to a running container.
docker attachwill connect to a working container.
docker psshows the working containers.
docker logsgets the logs from the container.
docker inspectgets all the information about a container (including the IP address).
docker eventsgets events from the container.
docker portshows the public port of the container.
docker topshows the processes running in the container.
docker statsshows statistics on the use of container resources.
docker diffshows the modified files in the container's filesystem.
docker ps -ashows the working and stopped containers.
docker stats --allshows the list of running containers.
Import / Export
docker cpcopies files or folders between a container and the local filesystem.
docker exporttransforms the container filesystem into the tarball archive stream in STDOUT.
The images are container templates. At this link you can find more information about images.
docker imagesshows all images.
docker importcreates an image from a tarball.
docker buildcreates an image from Dockerfile.
docker commitcreates an image from a container, temporarily interrupting it if it is running.
docker rmiremoves an image.
docker loadloads an image from a tar archive like STDIN, including images and tags (starting at 0.7).
docker savesaves an image in a tar archive stream on STDOUT with all levels, tags and parent versions (starting at 0.7).
docker historyshows the history of the image.
docker tagtags an image with a name (local or registry).
For further useful tips, visit this link.