4

I'm using Alpine Linux as a base for my containers, so no iptables for me, and I would rather not have to add it only for that.

I found this answer: https://stackoverflow.com/a/42336592/1326863 that tells that it is possible to disable internet in a docker's network, but is it possible to do it in docker-compose configuration?

Łukasz Zaroda
  • 869
  • 2
  • 19
  • 55

1 Answers1

0

This db container cannot reach the Internet in my tests:

version: '3'

services:
  db:
    image: postgres:alpine

networks:
  default:
    internal: true
Ralf Stubner
  • 26,263
  • 3
  • 40
  • 75
  • 6
    This doesn't seem to answer the question (blocking outgoing connections), since it also blocks incoming connections. I need a container to be accessible from the outside worlds by exposing ports, but also block outgoing connections from that container. – Nohus Jun 14 '20 at 19:43
  • @Nohus The answer seems to have answered the original question, since the OP accepted it. Feel free to ask a new question if you have a different one. Note that the answer might involve iptables, which the OP had excluded. – Ralf Stubner Jun 14 '20 at 21:53