Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: how to set proxy in cog.yaml or cog command or API call code when building an image? #873

Closed
Albert-cord opened this issue Jan 14, 2023 · 3 comments

Comments

@Albert-cord
Copy link

Albert-cord commented Jan 14, 2023

Hello. Thanks for your great job.
I wanna try running model repo with cog.
but I met a error below:

Building Docker image from environment in cog.yaml as style-your-hair-model...
[+] Building 6.4s (11/25)                                                                                                                                                                       
 => [internal] load build definition from Dockerfile                                                                                                                                       0.0s
 => => transferring dockerfile: 3.24kB                                                                                                                                                     0.0s
 => [internal] load .dockerignore                                                                                                                                                          0.0s
 => => transferring context: 2B                                                                                                                                                            0.0s
 => resolve image config for docker.io/docker/dockerfile:1.2                                                                                                                               2.5s
 => CACHED docker-image://docker.io/docker/dockerfile:1.2@sha256:e2a8561e419ab1ba6b2fe6cbdf49fd92b95912df1cf7d313c3e2230a333fdbcc                                                          0.0s
 => [internal] load metadata for docker.io/nvidia/cuda:10.2-cudnn8-devel-ubuntu18.04                                                                                                       1.9s
 => [stage-0  1/19] FROM docker.io/nvidia/cuda:10.2-cudnn8-devel-ubuntu18.04@sha256:54eff7aa01217a1fb039cf5dbfa925a4bce2073b1742074c84dd83cf7af4ab11                                       0.0s
 => [internal] load build context                                                                                                                                                          0.0s
 => => transferring context: 49.17kB                                                                                                                                                       0.0s
 => CACHED [stage-0  2/19] RUN rm -f /etc/apt/sources.list.d/cuda.list &&     rm -f /etc/apt/sources.list.d/nvidia-ml.list &&     apt-key del 7fa2af80                                     0.0s
 => CACHED [stage-0  3/19] RUN --mount=type=cache,target=/var/cache/apt set -eux; apt-get update -qq; apt-get install -qqy --no-install-recommends curl; rm -rf /var/lib/apt/lists/*; TIN  0.0s
 => CACHED [stage-0  4/19] RUN --mount=type=cache,target=/var/cache/apt apt-get update -qq && apt-get install -qqy --no-install-recommends  make  build-essential  libssl-dev  zlib1g-dev  0.0s
 => ERROR [stage-0  5/19] RUN curl -s -S -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash &&  git clone https://github.com/momo-lab/pyenv-ins  1.7s
------                                                                                                                                                                                          
 > [stage-0  5/19] RUN curl -s -S -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash &&       git clone https://github.com/momo-lab/pyenv-install-latest.git "$(pyenv root)"/plugins/pyenv-install-latest &&  pyenv install-latest "3.8" &&   pyenv global $(pyenv install-latest --print "3.8") &&   pip install "wheel<1":                          
#10 0.328 curl: (6) Could not resolve host: raw.githubusercontent.com
#10 0.332 /bin/sh: 1: pyenv: not found
#10 0.339 Cloning into '/plugins/pyenv-install-latest'...
#10 1.708 /bin/sh: 1: pyenv: not found
------
executor failed running [/bin/sh -c curl -s -S -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash &&  git clone https://github.com/momo-lab/pyenv-install-latest.git "$(pyenv root)"/plugins/pyenv-install-latest &&  pyenv install-latest "3.8" &&   pyenv global $(pyenv install-latest --print "3.8") &&   pip install "wheel<1"]: exit code: 127
ⅹ Failed to build Docker image: exit status 1

and I test my proxy with a test DockerFile,

FROM ubuntu
RUN apt update
RUN apt install -y git
RUN apt install -y curl
RUN cd ~
# RUN git clone https://github.com/momo-lab/pyenv-install
RUN echo $(curl -s -S -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer) > ~/test.text

and the result is fine because I had set a proxy setting in ~/.docker/config.json

[+] Building 0.1s (10/10) FINISHED                                                                                                                                                              
 => [internal] load build definition from Dockerfile                                                                                                                                       0.0s
 => => transferring dockerfile: 309B                                                                                                                                                       0.0s
 => [internal] load .dockerignore                                                                                                                                                          0.0s
 => => transferring context: 2B                                                                                                                                                            0.0s
 => [internal] load metadata for docker.io/library/ubuntu:latest                                                                                                                           0.0s
 => [1/6] FROM docker.io/library/ubuntu                                                                                                                                                    0.0s
 => CACHED [2/6] RUN apt update                                                                                                                                                            0.0s
 => CACHED [3/6] RUN apt install -y git                                                                                                                                                    0.0s
 => CACHED [4/6] RUN apt install -y curl                                                                                                                                                   0.0s
 => CACHED [5/6] RUN cd ~                                                                                                                                                                  0.0s
 => CACHED [6/6] RUN echo $(curl -s -S -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer) > ~/test.text                                                0.0s
 => exporting to image                                                                                                                                                                     0.0s
 => => exporting layers                                                                                                                                                                    0.0s
 => => writing image sha256:a6c4607e62d22ee21dcdb4bd1a8b9711cf758c24ea4157ae1c090edbd4bdbc70                                                                                               0.0s
 => => naming to docker.io/library/proxy_test:v3

how to set proxy in cog.yaml or cog command or API call code when building an image?
and another question, if I run a container instance built by cog, will it access the internet with my proxy also?

@Albert-cord
Copy link
Author

and provide a context below,
windows os version:

Edition	Windows 10 Pro
Version	22H2
Installed on	‎11/‎17/‎2020
OS build	19045.2364
Experience	Windows Feature Experience Pack 120.2212.4190.0

wsl2 Linux kernel version:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.1 LTS
Release:        20.04
Codename:       focal

docker version:

Client:
 Version:           20.10.12
 API version:       1.41
 Go version:        go1.16.2
 Git commit:        20.10.12-0ubuntu2~20.04.1
 Built:             Wed Apr  6 02:14:38 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Desktop
 Engine:
  Version:          20.10.22
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.18.9
  Git commit:       42c8b31
  Built:            Thu Dec 15 22:26:14 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.14
  GitCommit:        9ba4b250366a5ddde94bb7c9d1def331423aa323
 runc:
  Version:          1.1.4
  GitCommit:        v1.1.4-0-g5fd4c4d
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

@Albert-cord
Copy link
Author

I dive into the code, and just found call os/exec.Command("docker, args...") to use docker to process remaining work.
I have no idea why have a difference between I run docker build in my wsl2 shell and I use cog to build an image.
the code which cog build docker image

@schneiderlin
Copy link

have you solve the probleam?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants