File: Dockerfile

package info (click to toggle)
rust-cntr 1.6.0-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 552 kB
  • sloc: sh: 20; makefile: 17
file content (25 lines) | stat: -rw-r--r-- 1,044 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Example for a slim/fat container setup

FROM rust:1.84.0 as cntr
RUN rustup target add x86_64-unknown-linux-musl
RUN curl -sL https://github.com/Mic92/docker-pid/releases/download/1.0.2/docker-pid-linux-amd64 \
      > /usr/bin/docker-pid && \
      chmod 755 /usr/bin/docker-pid
COPY Cargo.toml Cargo.lock ./
# weird trick to cache crates
RUN cargo build --release --target=x86_64-unknown-linux-musl || true
COPY src ./src/
RUN cargo build --release --target=x86_64-unknown-linux-musl
RUN strip target/x86_64-unknown-linux-musl/release/cntr -o /usr/bin/cntr

FROM busybox
WORKDIR /root/
COPY --from=cntr /usr/bin/cntr /usr/bin/cntr
COPY --from=cntr /usr/bin/docker-pid /usr/bin/docker-pid
ENTRYPOINT ["/usr/bin/cntr"]

# Build with:
# $ docker build . -t cntr
# Assuming you have a container called mycontainer, you want to attach to (docker run --name mycontainer -ti --rm busybox sh)
# you can then run:
# $ sudo docker run --pid=host --privileged=true -v /var/run/docker.sock:/var/run/docker.sock -ti --rm cntr attach mycontainer /bin/sh