0

I am a newbie to Docker so apologies in advance for any incorrect statements. System: MacOS Ventura (13.2.1) running on arm64/aarch64/M1, 32GB RAM

The high-level context is to instantiate a Cosmos blockchain node in a ubuntu container because the rust (wasm) code does not currently compile on masOS. I am actually dealing with three containers:

-- MacOS
====| -- Container1 (golang): this works fine
==========| -- Container2 (wasmd): this works fine
==========| -- Container3 (rust-optimizer): this is where the problem is

So I need to instantiate a container (rust-optimizer) running within another container (ubuntu), which is itself running on my system. I tried using the docker image from DockerHub but it's an alpine and installing Go on that turned out to be a nightmare. It was much easier to start with the golang image and install docker on that. This worked well and my wasmd node is running locally.

Within Container 1 I tried to instantiate a third container, Container3, and that's where I got the error. I will paste my Dockerfile for the first image from which Container1 is instantiated. I will add all the steps to finally get to the error. I will then paste two links that seem related to my error.

Dockerfile:

FROM --platform=linux/amd64 golang:latest
# Update package manager and install basic utilities:
RUN apt-get -y update && upgrade
RUN apt-get install -y openssh-client && bash && build-essential && curl && git && vim
RUN apt-get clean
# Install rust:
ENV PATH="/root/.cargo/bin:${PATH}"
RUN curl --proto '=https' --tlsv1.2 -sSf \ https://sh.rustup.rs | bash -s -- -y --default-toolchain nightly
RUN git clone https://github.com/twilight-rs/http-proxy.git
RUN cd http-proxy && . $HOME/.cargo/env && cargo +nightly build --release -Z sparse-registry
RUN rustup target add wasm32-unknown-unknown
# Install Docker:
RUN curl -fsSL https://get.docker.com | sh
# Install wasmd:
RUN git clone https://github.com/CosmWasm/wasmd.git && cd wasmd && make install
# Dowload code over SSH:
RUN mkdir -p -m 0700 ${HOME}/.ssh && ssh-keyscan github.com >> ${HOME}/.ssh/known_hosts
ENV GIT_SSH_COMMAND="ssh -i /run/secrets/id_ed25519"
# Clone the conf files into the docker container
RUN --mount=type=secret,id=id_ed25519 git clone git@github.com:<myRepo>.git

Build command

docker build -t myImage --secret id=id_ed25519,src=${HOME}/.ssh/id_ed25519 .

Container1 command

docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock myImage

After launching Container2, I opened another bash session on Container1 in order to launch Container3. Here I saw that myRepo had been installed under /go rather than under /root. I tried what follows from both locations, i.e. first without moving it and then moving it to /root, but got the same exact response. The command I used is this:

docker run --rm -v "$(pwd)":/code \
    --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
    --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/rust-optimizer:0.12.8

The error message is this: docker:

Error response from daemon: Mounts denied:
The path /root/myRepo is not shared from the host and is not known to Docker.
You can configure shared paths from Docker -> Preferences... -> Resources -> File Sharing.
See https://docs.docker.com/desktop/mac for more info.
ERRO[0001] error waiting for container:

The two links I found that are close to answering this problem are this and this. The problem is that both refer to the underlying macOS environment and to the Docker Desktop options I can set there. But the mount share problem is between Container1 and Container3, not between macOS and Container1. The point is that Container1 and Container3 are both Linux-based, therefore the macOS sharing restrictions should not apply. So I am lost and would appreciate some help sorting this out.

pdini
  • 101
  • 1
  • It [looks like](https://github.com/CosmWasm/rust-optimizer) the intended use of the `cosmwasm/rust-optimizer` tool is to run once at build time to produce a `*.wasm` file; can you launch that from your host, running on your local source tree, without adding an additional Docker layer around it? That would simplify this workflow considerably and bring it closer to a typical compile-and-run setup. – David Maze Mar 09 '23 at 18:31
  • You are right @DavidMaze, I did not need Container3 to complete the build, I can just do it within Container1. As one of my colleagues explained, the rationale for Container3 is reproducibility with checksums, which is important for production, but for development it's overkill. – pdini Mar 10 '23 at 13:57

0 Answers0