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

Docker-in-Docker GitLab CI #513

Closed
netzdoktor opened this issue Jan 25, 2021 · 6 comments
Closed

Docker-in-Docker GitLab CI #513

netzdoktor opened this issue Jan 25, 2021 · 6 comments

Comments

@netzdoktor
Copy link

I am using cross in a docker-in-docker scenario on GitLab CI. I used the approach given in #273 (comment), which unfortunately did not work anymore. I am still getting:

sh: 1: cargo: not found

So I used CROSS_DOCKER_IN_DOCKER=true (as recommended in another comment) and the result is this:

error: `"/usr/bin/docker" "inspect" "runner-27oc64mp-project-587-concurrent-0"` failed with exit code: Some(1)

I have the latest release of cross installed (but checking a diff with master didn't reveal relevant changes as far as I can tell).

I am wondering why this does not work in the GitLab environment...

Thanks in advance!

@gaoyifan
Copy link

gaoyifan commented Feb 8, 2021

Gitlab runner set a different hostname, which is not equal to conatiner name. eg:

container name:  runner-dtfmkqbc-project-33-concurrent-0-22fbe3329596e791-build-2
hostname:        runner-dtfmkqbc-project-33-concurrent-0

In cross, we assume that hostname is equal to container name:
https:/rust-embedded/cross/blob/4f213ba07b214d36225be63e5b72a6346937a699/src/docker.rs#L235-L237

I have not find a solution yet.

@gaoyifan
Copy link

gaoyifan commented Feb 8, 2021

Workaround:

  script:
    - export HOSTNAME=$(docker ps -ql)
    - cross build ...

@Kaiser1989
Copy link

Workaround:

  script:
    - export HOSTNAME=$(docker ps -ql)
    - cross build ...

Calling $(docker ps -ql) returns empty string in my case. Are there any other possibilities to get correct container name?

@Alexhuszagh
Copy link
Contributor

Alexhuszagh commented May 29, 2022

Calling $(docker ps -ql) returns empty string in my case. Are there any other possibilities to get correct container name?

That suggests there are no created containers, of any state (running or stopped). Try using docker ps -a to print all running containers, which I expect would be empty.

@Alexhuszagh
Copy link
Contributor

This is a duplicate of #273. We've documented how to use docker-in-docker, remote docker (required if Gitlab is using a remote Docker connection, such as with a host at tcp://docker:2375/).

@sybernomad
Copy link

Workaround:

  script:
    - export HOSTNAME=$(docker ps -ql)
    - cross build ...

This didn't work for me when I had multiple cross builds running in parallel. I got around it by doing this instead:

   script:
     - export HOSTNAME=$(docker ps -aqf "name=^$HOSTNAME" | awk 'NR==1{print $1}')
     - cross build ...

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

No branches or pull requests

5 participants