0

I would like to create a Docker image with a Rust/cargo binary such that all users can use said binary. This successfully builds the image

FROM ubuntu:jammy

RUN apt-get --yes install cargo
RUN cargo install oxipng
ENV PATH="${PATH}:/root/.cargo/bin"
RUN oxipng --help

but when using it, /root/.cargo/bin is not in the path.

How can I add the path to the default system $PATH?

Nico Schlömer
  • 53,797
  • 27
  • 201
  • 249
  • Are the quotes in the `ENV` line causing a problem? Docker does not run a shell, and I might guess it's including the quotes as part of the variable value. If you had a directory named `/root/.cargo/bin"` with the quote as part of the directory name, that might be the last `$PATH` component. – David Maze Jun 30 '23 at 13:10
  • 1
    (It's possible the [`rust`](https://hub.docker.com/_/rust) image will be easier to work with here.) – David Maze Jun 30 '23 at 13:11

1 Answers1

0

This might be a duplicate of In a Dockerfile, How to update PATH environment variable? - you're doing it right, I tried it and the PATH contains /root/.cargo/bin in the PATH env

Hernan Garcia
  • 1,416
  • 1
  • 13
  • 24