-d: Run in detached mode
-e: Set new environment variable
--env-file: use an external file for env variables
-i: Keep the Standard Input open
-t: pseudo Terminal (TTY)
-u: define a user for the command
-w: define a working dir inside the container
...
The most common use case:
Use the exec command to get inside a running container
Example:
`docker exec -it <container_id> bash`
This works for most of the containers running based on Linux images
...
If you use Alpine distributions, you could not have a bash.
in this case, you can use sh:
`docker exec -it <container_id> sh`
As an alternative, you can install the bash in the Dockerfile.
...
Another use Case
If you use Postgres and you wanna see the database directly from the Postgres container is:
`docker exec -it <container_id> psql -U Postgres
• • •
Missing some Tweet in this thread? You can try to
force a refresh
There are many resources online, many great ones even free to learn Docker
But what is the path to learning Docker from Zero, so you can choose your own videos/articles?
Here is the path I suggest in 10 steps.
Let's see them together:
...
1) Understanding WHAT it is and what it isn't, what are the building blocks of it
2) Understanding what containerization is and why it is so important. Differences Containers/Virtual Machines
3) Install Docker on your operating system and make sure it works (`docker info`)
...
4) Take a look at "Docker Hub" and make a bit of practice using one image there (eg Nginx) and understand the basic commands: start/stop/list containers.
5) Understand how the components are made and their configuration: commands inspect/exec/logs.
and me, because I create content about it every single day.
WHAT is Docker?
A container technology, a platform to build and manage containers.
You package the code with all the dependencies you need in order to run your application everywhere in a smart, reliable way.
Think about it as a Mountain Backpack, you can bring with you
The instruction is not case-sensitive, but the convention is to be UPPERCASE to distinguish them from arguments more easily.
add # to add a single-line comment
... 2/25
.dockerignore
Before sending the context to the Docker daemon, the Docker CLI checks if a .dockerignore file is in the root directory. If so it excludes files/dirs that match patterns in it.
The Docker client talks to the Docker daemon (server), which menages different docker objects:
- Images
- Containers
- Networks
- Volumes
Let's see in details:
... 1/12
The Docker client and the daemon can run on the same system, or they can be connected remotely using HTTP protocol.
The connection is established using REST APIs, over UNIX sockets/network interface
... 2/12
DOCKER DAEMON (SERVER)
The Docker daemon (dockerd) is a process, which runs in the background, that manages the docker objects (images, containers, networks, volumes). It processes Docker API requests