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

apt-get not work in dockerfile #1552

Closed
3 of 11 tasks
h3zh1 opened this issue Sep 2, 2024 · 8 comments
Closed
3 of 11 tasks

apt-get not work in dockerfile #1552

h3zh1 opened this issue Sep 2, 2024 · 8 comments

Comments

@h3zh1
Copy link

h3zh1 commented Sep 2, 2024

Checklist

Describe your issue

I tried to build the docker image locally, I used apt to download g++-x86-64-linux-gnu and protobuf-compiler etc. But these don't seem to take effect. Can I only define them in pre-build or .sh?
cargo build image:
image
the content in Dockerfile
image
But apt cannot find it
image

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

x86_64-unknown-linux-gnu

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.5 (d8631fe 2024-08-17)

Example

No response

Additional information / notes

No response

@Emilgardis
Copy link
Member

I'm not sure what these screenshots are supposed to show. Where is the installation logs? Why is RUN /xargo.sh underlined?

@h3zh1
Copy link
Author

h3zh1 commented Sep 2, 2024

Sorry, my picture is not particularly accurate. The underline is to show that RUN apt... is not executed under cargo.
pic1: I pulled the image from ghcr.io and ran apt list to find it. I couldn't find the corresponding package "https://github.com/cross-rs/cross/blob/main/docker/Dockerfile.x86_64-unknown-linux-gnu#L15"
image
pic2: I re-run cargo build-docker-image x86_64-unknown-linux-gnu --tag latest --no -cache, the new screenshot is as follows
image

@Emilgardis
Copy link
Member

Emilgardis commented Sep 2, 2024

the image built with cargo build-docker-image is tagged with :local, not :main
There's also some confusion here about what Dockerfile cargo build-docker-image x86-64-unknown-linux-gnu uses, it actually uses Dockerfile.native when target=platform

@h3zh1
Copy link
Author

h3zh1 commented Sep 3, 2024

Oh, it seems that he parsed Dockerfile.native instead of "Dockerfile.x86_64-unknown-linux-gnu"

@h3zh1
Copy link
Author

h3zh1 commented Sep 3, 2024

When the target is "x86_64-unknown-linux-gnu", Dockerfile.native is loaded.
But when the target is "i686-unknown-linux-gnu", Dockerfile.i686-unknown-linux-gnu is loaded correctly.
image

And I tried to use another ubuntu to execute cargo build-docker-image i686-unknown-linux-gnu --tag local and cargo build-docker-image x86_64-unknown-linux-gnu --tag local, error still exists
image

@Emilgardis
Copy link
Member

Yes, that is not a problem, it's supposed to be that way.

I'm not sure what this issue is about anymore, can we close it?

@h3zh1
Copy link
Author

h3zh1 commented Sep 4, 2024

Now I understand the usage, but loading Dockerfile.native is a little uncomfortable when I build image for "x86_64-unknown-linux-gnu" locally. Thanks, we can close it.

@Emilgardis
Copy link
Member

To explain a bit, the reason .native is used is because we want to support using the images for other platforms. On x86_64-unknown-linux-gnu we cant install libc6-dev-amd64-cross, we just install libc6, so to make it easy, when image platform=target, we switch to .native

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