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

Invalid Docker Tags in Custom Docker Images #894

Closed
2 of 11 tasks
Alexhuszagh opened this issue Jul 1, 2022 · 1 comment · Fixed by #895
Closed
2 of 11 tasks

Invalid Docker Tags in Custom Docker Images #894

Alexhuszagh opened this issue Jul 1, 2022 · 1 comment · Fixed by #895
Assignees
Labels
A-container-engine Area: container engines bug

Comments

@Alexhuszagh
Copy link
Contributor

Alexhuszagh commented Jul 1, 2022

Checklist

Describe your issue

Currently, if a project directory (inadvisably) contains invalid characters for a Docker tag, this will cause a build with pre-build hooks or a custom Dockerfile to fail.

A working example available here.

This produces the following errors:

$  cross build --target x86_64-unknown-linux-gnu --verbose
+ cargo metadata --format-version 1 --filter-platform x86_64-unknown-linux-gnu
+ rustc --print sysroot
+ rustup toolchain list
+ rustup target list --toolchain stable-x86_64-unknown-linux-gnu
+ rustup component list --toolchain stable-x86_64-unknown-linux-gnu
+ /usr/bin/docker
+ "/home/ahuszagh/git/CrossPrebuildUppercase" /usr/bin/docker build --label 'org.cross-rs.for-cross-target=x86_64-unknown-linux-gnu' --label 'org.cross-rs.workspace_root=/home/ahuszagh/git/CrossPrebuildUppercase' --tag cross-custom-CrossPrebuildUppercase:x86_64-unknown-linux-gnu-d59ad-pre-build --build-arg 'CROSS_CMD=apt-get update' --build-arg 'CROSS_DEB_ARCH=amd64' --file /home/ahuszagh/git/CrossPrebuildUppercase/target/x86_64-unknown-linux-gnu/Dockerfile.x86_64-unknown-linux-gnu-custom .
invalid argument "cross-custom-CrossPrebuildUppercase:x86_64-unknown-linux-gnu-d59ad-pre-build" for "-t, --tag" flag: invalid reference format: repository name must be lowercase
See 'docker build --help'.
Error: 
   0: could not run container
   1: when building custom image
   2: when pre-building
   3: `/usr/bin/docker build --label 'org.cross-rs.for-cross-target=x86_64-unknown-linux-gnu' --label 'org.cross-rs.workspace_root=/home/ahuszagh/git/CrossPrebuildUppercase' --tag cross-custom-CrossPrebuildUppercase:x86_64-unknown-linux-gnu-d59ad-pre-build --build-arg 'CROSS_CMD=apt-get update' --build-arg 'CROSS_DEB_ARCH=amd64' --file /home/ahuszagh/git/CrossPrebuildUppercase/target/x86_64-unknown-linux-gnu/Dockerfile.x86_64-unknown-linux-gnu-custom .` failed with exit status: 125

Note: CROSS_CMD=apt-get update

What target(s) are you cross-compiling for?

No response

Which operating system is the host (e.g computer cross is on) running?

  • macOS
  • Windows
  • Linux / BSD
  • other OS (specify in description)

What architecture is the host?

  • x86_64 / AMD64
  • arm32
  • arm64 (including Mac M1)

What container engine is cross using?

  • docker
  • podman
  • other container engine (specify in description)

cross version

cross 0.2.2 (latest main)

Example

No response

Additional information / notes

No response

@Alexhuszagh
Copy link
Contributor Author

Since we can't guarantee the workspace root has a package name, it's probably a good idea to just replace any invalid characters (go to_lowercase(), and remove any other invalid characters).

@Alexhuszagh Alexhuszagh added A-container-engine Area: container engines and removed container-images labels Jul 1, 2022
@Alexhuszagh Alexhuszagh changed the title Pre-Build Hook Issues Invalid Docker Tags in Custom Docker Images Jul 1, 2022
@bors bors bot closed this as completed in 9f814c6 Jul 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-container-engine Area: container engines bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant