Compose: networks option for build

Created on 30 Oct 2016  路  11Comments  路  Source: docker/compose

The --network option for docker build has been recently merged. Please support it in Compose too. Something like this:

build:
  context: ./dir
  networks:
    - some-network
    - other-network
arebuild arenetworking docker-py kinfeature kinparity

Most helpful comment

https://stackoverflow.com/a/47545276/340760

version: '3.4'
services:
  my_image:
    build:
      context: .
      network: host

All 11 comments

Thank you for the suggestion - we'll look into it as we get closer to the 1.13 Engine release.

1.13.0-rc1 has been released. Any thoughts on this? Thanks

actually 1.13 has already been released with the --network flag for build. anything new for this issue?

+1

I would like this our environment as well. We have some services are that required during the build process, that should be linked to the building containers for abstraction.

https://stackoverflow.com/a/47545276/340760

version: '3.4'
services:
  my_image:
    build:
      context: .
      network: host

And how do you determine the yaml version that your docker-compose is compatible with?

$ docker-compose -v
docker-compose version 1.17.1, build 6d101fb

$ docker-compose version
docker-compose version 1.17.1, build 6d101fb
docker-py version: 2.5.1
CPython version: 2.7.12
OpenSSL version: OpenSSL 1.0.2j  26 Sep 2016

Is not helpful.

you can check https://github.com/docker/compose/releases/ and I think I saw it somewhere in the docs too

馃悰 _For those encountering network not found issue:_
Issue: Service X failed to build: network Y not found.
Solution: Docker doesn't resolve the project name for the build network, it should be specified explicitly.
<networkName> -> <projectName>_<networkName>
Project name can be specified during execution:
docker-compose --project-name <projectName> build <serviceName>

@myuseringithub 's fix works. This should be resolved for us. I'll search for an existing ticket...

Was this page helpful?
0 / 5 - 0 ratings