Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker offline network

How can I create network without connect to internet?

I have 2 docker networks offline and online and i need disable internet connection for all containers in my offline network

enter image description here

And I have docker-compose file like that

some_offline_container:
    build:
      context: ./offline/first-container
    networks:
      - offline
 networks:
    online:
    offline:
like image 205
frankegoesdown Avatar asked Aug 14 '18 10:08

frankegoesdown


People also ask

What are the networking concerns with Docker containers?

This topic is about networking concerns from the point of view of the container. By default, when you create or run a container using docker create or docker run , it does not publish any of its ports to the outside world.

What is a bridge network in Docker?

Bridge networks are usually used when your applications run in standalone containers that need to communicate. See bridge networks. host: For standalone containers, remove network isolation between the container and the Docker host, and use the host’s networking directly. See use the host network.

What is the Docker network adapter?

This adapter is created when Docker is installed on the Docker Host. This is a bridge between the Docker Host and the Linux Host. Now let’s look at some commands associated with networking in Docker.

How do I run a docker container on Windows?

Windows Home or Education editions will only allow you to run Linux containers. Double-click Docker Desktop Installer.exe to run the installer. If you haven’t already downloaded the installer ( Docker Desktop Installer.exe ), you can get it from Docker Hub .


1 Answers

Is the internal flag sufficient for your use case?

When you specify this option you create a network that doesn’t allow access to communicate with external networks. In the following example, you would have an isolated network called my_internal_network without internet access.

version: '3'
services:
  h1:
    image: "httpd"
    networks:
      - my_internal_network
  h2:
    image: "httpd"
    networks:
      - my_internal_network
  h3:
    image: "httpd"
    networks:
      - my_network
networks:
  my_internal_network:
    driver: bridge
    internal: true  # restrict external access to the network
  my_network:
    driver: bridge
like image 192
Yannic Hamann Avatar answered Sep 27 '22 23:09

Yannic Hamann