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

[bug] Docker runner does not honor custom container name #16234

Closed
uilianries opened this issue May 10, 2024 · 2 comments
Closed

[bug] Docker runner does not honor custom container name #16234

uilianries opened this issue May 10, 2024 · 2 comments
Assignees
Milestone

Comments

@uilianries
Copy link
Member

Describe the bug

When trying to use official ConanDockerTools images with the new feature Docker runners, I wanted to use a custom container name (e.g conan_linux_gcc11), however, the current behavior uses image name instead and ignores my configuration file.

conan create all --version=1.0.1 -pr linux-gcc11                                                                                                                     

======== Exporting recipe to the cache ========
paho-mqtt-cpp/1.0.1: Exporting package recipe: /Users/uilian/Development/conan/conan-center-index/recipes/paho-mqtt-cpp/all/conanfile.py
paho-mqtt-cpp/1.0.1: exports: File 'conandata.yml' found. Exporting it...
paho-mqtt-cpp/1.0.1: Calling export_sources()
paho-mqtt-cpp/1.0.1: Copied 1 '.py' file: conanfile.py
paho-mqtt-cpp/1.0.1: Copied 1 '.yml' file: conandata.yml
paho-mqtt-cpp/1.0.1: Copied 1 '.patch' file: 1.0.1-0001-fix-cmake.patch
paho-mqtt-cpp/1.0.1: Exported to cache folder: /Users/uilian/.conan2/p/paho-c2a77d934f3de/e
paho-mqtt-cpp/1.0.1: Exported: paho-mqtt-cpp/1.0.1#f7c87fa70a8dc4d8274efeb500f73320 (2024-05-10 10:03:04 UTC)

======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=17
compiler.libcxx=libstdc++11
compiler.version=11
os=Linux
[conf]


Profile build:
[settings]
arch=armv8
build_type=Release
compiler=apple-clang
compiler.cppstd=17
compiler.libcxx=libc++
compiler.version=15
os=Macos
[conf]



┌───────────────────────────────┐
| Creating the docker container |
└───────────────────────────────┘

ERROR: Imposible to run the container "conanio/gcc11-ubuntu16.04:2.3.0" with image "conanio/gcc11-ubuntu16.04:2.3.0"

400 Client Error for http+docker://localhost/v1.43/containers/create?name=conanio%2Fgcc11-ubuntu16.04%3A2.3.0: Bad Request ("Invalid container name (conanio/gcc11-ubuntu16.04:2.3.0), only [a-zA-Z0-9][a-zA-Z0-9_.-] are allowed")

The 🐛 is because the code is passing the image name instead of the container name to Docker:

https://github.com/conan-io/conan/blob/2.3.0/conan/internal/runner/docker.py#L114

🍔

/cc @davidsanfal

Environment

OS: OSX 14.4.1 (23E224)
Arch: Mac M1 MAX
Conan version: 2.3.0
Docker version: 25.0.4-rd
Rancher version: 1.13.1

How to reproduce it

To reproduce this error in Mac, I need a profile file and a configuration file, plus, the docker image downloaded.

# ~/.conan2/profiles/linux-gcc11
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=17
compiler.libcxx=libstdc++11
compiler.version=11
os=Linux

[runner]
type=docker
cache=clean
remove=true
configfile=/Users/uilian/.conan2/runners/linux-gcc11
# ~/.conan2/runners/linux-gcc11
image: conanio/gcc11-ubuntu16.04:2.3.0
run:
    name: conan_linux_gcc11
    containerUser: conan
    privileged: False

Once you have these files in your Conan cache folder, you will need to run:

docker pull conanio/gcc11-ubuntu16.04:2.3.0
conan new cmake_lib -d name=foo -d version=0.1.0
conan create . -pr:b default -pr:h linux-gcc11

(I ran docker pull separated only to illustrate)

@AbrilRBS
Copy link
Member

Asked @uilianries to fix this so that it's ready for 2.3.1 as David is away this week :)

@memsharded
Copy link
Member

Closed by #16243 for next 2.3.1

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

4 participants