|
|
## Description
|
|
|
The main concept behind Docker is the use of containers. A container is an isolated sandbox in which ideally you run one single process that accomplishes one single task: for its nature, the container is isolated and cannot communicate with the host machine. The only thing shared by default is the kernel. If you want to communicate with the container there are several configurations/options that must be set when you run the container.
|
|
|
|
|
|
![container_schema](uploads/943401e428520074ff3f85a1d040c636/container_schema.png)
|
|
|
|
|
|
## File/Directory sharing
|
|
|
In order to share a file or a directory, you can create a volume. There are three types of volumes:
|
|
|
|
|
|
* named volumes
|
|
|
* anonymous volumes
|
|
|
* volumes on mount
|
|
|
|
|
|
##### Named volume
|
|
|
A named volume is a volume created by Docker associated with a name. The real content of the volume is store inside `/var/lib/docker/volumes` and the user can interact with it using Docker command and the volume name.
|
|
|
|
|
|
##### Anonymous volume
|
|
|
An anonymous volume is very similar to a named volume, the main difference is that users do not provide the name during the creation. The content of the volume is stored inside `/var/lib/docker/volumes` directory and the identifier is a hash function output.
|
|
|
|
|
|
##### Volume on mount
|
|
|
Volume on mount is the most common and used type of volume. If you have a directory like this
|
|
|
|
|
|
![dir_example](uploads/e2fe848215823c069589d1cb92d08717/dir_example.png)
|
|
|
|
|
|
and you want to have the same exact content inside the container you can map the host dir to a container dir using this syntax:
|
|
|
```
|
|
|
/path/to/my_dir/dataset:/path/in/which/I/want/data
|
|
|
```
|
|
|
If you plan to only read and not modify the data folder you can mount/map the directory using the `:ro` suffix.
|
|
|
```
|
|
|
/path/to/my_dir/dataset:/path/in/which/I/want/data:ro
|
|
|
```
|
|
|
This suffix prevents Docker to write inside that directory.
|
|
|
|
|
|
This type of volume is supported with the [configuration file](https://gitlab.fbk.eu/dsip/templates/dl_setup/-/wikis/Configuration-file)
|
|
|
|
|
|
## Network sharing
|
|
|
In order to be able to communicate through a socket, you can specify one or more ports that will be used to establish network communication.
|
|
|
For example, you have a database inside a container hosted on port 65432 and you want to access it from your host machine through port 8765. You can do this using `-p` options:
|
|
|
```
|
|
|
-p 8765:65432
|
|
|
```
|
|
|
After that the host port number 8765 is like container port 65432 and the container port 65432 is like host port 8765.
|
|
|
|
|
|
This option is supported with the [configuration file](https://gitlab.fbk.eu/dsip/templates/dl_setup/-/wikis/Configuration-file)
|
|
|
|
|
|
## Interactive shell
|
|
|
By default, Docker container can't receive input from the keyboard when launched. If you want to interact with it you can use `-it` option.
|
|
|
|
|
|
This option is supported with the [configuration file](https://gitlab.fbk.eu/dsip/templates/dl_setup/-/wikis/Configuration-file) |
|
|
\ No newline at end of file |