--- tags: [docker, docker-compose] --- ```shell docker create -it ubuntu:18.04 bash docker start docker attach docker exec docker ps -a ``` Подключиться к консоли контейнера: ```shell docker exec -ti /bin/bash docker attach ``` Построить контейнеры в директории с файлом `docker-compose.yaml` ```shell docker-compose up --build -d ``` Узнать IP конкретного контейнера ```shell docker exec cat /etc/hosts docker inspect --format '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ``` Узнать IP всех запущенных контейнеров: ```shell docker ps -q | xargs -n 1 docker inspect --format '{{ .Name }} {{range .NetworkSettings.Networks}} {{.IPAddress}}{{end}}' | sed 's#^/##'; docker-compose ps -q | xargs -n 1 docker inspect --format '{{ .Name }} {{range .NetworkSettings.Networks}} {{.IPAddress}}{{end}}' | sed 's#^/##'; ``` Docker-compose: подключить контейнеры к bridge хоста: > Adding network_mode: bridge to each service in your docker-compose.yml will stop compose from creating a network. If any service is not configured with this bridge (or host), a network will be created. Tested and confirmed with: ```yaml version: "3.1" services: app: image: ubuntu:latest network_mode: bridge ```