osrf / rocker

A tool to run docker containers with overlays and convenient options for things like GUIs etc.
Apache License 2.0
532 stars 68 forks source link

Command `rocker` execution under proxy #275

Closed NakanishiKM closed 3 months ago

NakanishiKM commented 3 months ago

Hi, When executing the command in a proxy environment, the following error was displayed. I felt that this error occurred when I could not connect to the external network.

When creating a docker image, I used the option ---build-arg http_proxy=<http://proxy:port> to connect to the network, but how should I do this with the command rocker?

$ rocker --x11 --nvidia --user --network=host --privileged --volume ./ -- ros:noetic Extension volume doesn't support default arguments. Please extend it. Active extensions ['network', 'nvidia', 'privileged', 'user', 'volume', 'x11'] Step 1/6 : FROM golang:1.19 as detector ---> 80b76a6c918c Step 2/6 : RUN git clone -q https://github.com/dekobon/distro-detect.git && cd distro-detect && git checkout -q 5f5b9c724b9d9a117732d2a4292e6288905734e1 && CGO_ENABLED=0 go build . ---> Running in 7daee16ebc89 fatal: unable to access 'https://github.com/dekobon/distro-detect.git/': Recv failure: Connection reset by peer

tfoote commented 3 months ago

It's recommended for you to create a Rocker Extension to support passing that through during the build stages.

There's a base class for the extension: https://github.com/osrf/rocker/blob/4078d223a2158e9a6fea31d8871dc7df7ee094f0/src/rocker/core.py#L61 And then you need to register it via setup.py

You can find some built in extensions in rocker (such as here https://github.com/osrf/rocker/blob/main/src/rocker/extensions.py) as well as several 3rdparty ones linked from the readme.

You can make your own package or open a PR back here if you think that it's generic enough. A build-argument extension I think would be useful.

Note that for this specifically you may want to consider using the docker config which looks like it can inject the proxy elements for you without the need for an ARG: https://docs.docker.com/network/proxy/#configure-the-docker-client

NakanishiKM commented 3 months ago

Thank you for response!

okay, I understood your suggestion and decided that it would be possible to extend the build-argument using that class. However, if an individual user has configured ./docker/config.json, it can pass the proxy there, so don't concern about the difficulties and just refer to own personal configuration file.

Thank you for your consultation!

tfoote commented 3 months ago

You're welcome, I think because the config option exists with native support from docker and can support both build and run time without an issue that I will suggest that it be the recommended approach and keep the implementation in rocker simpler and avoid that element of complexity.