–
How to publish a container port in the bridge network:
docker run -d -p 80:80 nginx
How to disable network isolation for a container:
docker run -d --rm --network host nginx
docker run
docker run --net ...
docker-compose
docker-compose.yml
docker-compose.yml
–
Containers in the same docker-compose.yml
are deployed to the same network:
docker-compose up -d
docker network ls
docker exec -it svc1 ping svc2
–
Containers launched over the mapped daemon socket do not end up in the same network context:
docker-compose \
--file docker-compose.yml \
--file docker-compose.context.yml \
up -d
docker-compose exec dind sh
Inside of the dind
service, start a new container:
docker run -it alpine
It will not be able to see any service from the docker-compose
files:
ping svc1
ping svc2
–
Continue to test inside the dind
service:
docker run -it --rm --network test_default alpine
Once the container is started in the network used by the deployment, it can see other services:
ping svc1
ping svc2