## Docker
### Start a container with a shell and mounted folder
```sh
docker run -it -v <shared_folder>:<mounting_path> <image>
```
### Get IP of running container
```sh
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <container_name_or_id>
```
### Disable address randomization
If GDB gives the error `warning: Error disabling address space randomization: Operation not permitted` than run the image with the following flags
```sh
docker run --cap-add=SYS_PTRACE --security-opt seccomp=unconfined
```
### Start an exited container
```sh
docker start -a <container_ID>
```
Sometimes the container doesn't work at all after this command, in that case run:
```sh
docker restart <container_ID>
docker attach <container_ID>
```
### Give access to host USB or serial device
```sh
docker run -it --device=/dev/ttyUSB0 <image>
```
### Create container from Dockerfile
Assuming there is a valid `Dockerfile` in the current folder, just run
```sh
docker build -t container_name .
```
### Adding volume to existing container
```sh
docker commit 5a8f89adeead newimagename
docker run -it -v "$PWD/dir1":/dir1 -v "$PWD/dir2":/dir2 newimagename
```