0

There is Containerfile inside substrate-node-template. What command should I use to run this file. Is the file is similar like DockerFile?

I try to run using docker build -f Containerfile -t node-template:latest . command but I got this error.

ganesholi@Ganeshs-MacBook-Air substrate-node-template % docker build -f Containerfile -t node-template:latest .
[+] Building 3.9s (8/9)                                                                                                                     docker:desktop-linux
 => [internal] load .dockerignore                                                                                                                           0.0s
 => => transferring context: 2B                                                                                                                             0.0s
 => [internal] load build definition from Containerfile                                                                                                     0.0s
 => => transferring dockerfile: 947B                                                                                                                        0.0s
 => [internal] load metadata for docker.io/library/ubuntu:22.04                                                                                             3.4s
 => [auth] library/ubuntu:pull token for registry-1.docker.io                                                                                               0.0s
 => CACHED [1/4] FROM docker.io/library/ubuntu:22.04@sha256:ec050c32e4a6085b423d36ecd025c0d3ff00c38ab93a3d71a460ff1c44fa6d77                                0.0s
 => [internal] load build context                                                                                                                           0.0s
 => => transferring context: 2B                                                                                                                             0.0s
 => CANCELED [2/4] RUN apt-get update &&  DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends   ca-certificates &&  apt-get autoremo  0.4s
 => ERROR [3/4] COPY --chown=polkadot:polkadot --chmod=774 node-template /usr/bin/node-template                                                             0.0s
------                                                                                                                                                           
 > [3/4] COPY --chown=polkadot:polkadot --chmod=774 node-template /usr/bin/node-template:
------
Containerfile:23
--------------------
  21 |     
  22 |     # copy the compiled binary to the container
  23 | >>> COPY --chown=polkadot:polkadot --chmod=774 node-template /usr/bin/node-template
  24 |     
  25 |     # check if executable works in this container
--------------------
ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref 57260b33-13ab-451b-9dbb-8cd096257614::rk2qq1n6p0a2l360xp3hgkrc0: "/node-template": not found
ganesholi@Ganeshs-MacBook-Air substrate-node-template % 

2 Answers 2

1
# copy the compiled binary to the container
COPY --chown=polkadot:polkadot --chmod=774 node-template /usr/bin/node-template

In fact, this line tries to copy ./node-template to the container. Since you are in the root dir, you should change your directory first.

cd ./target/release
docker build -f ../../Containerfile -t node-template:latest .
0

yes is similar to a Dockerfile and you can build/run as expected.

docker build -f Containerfile -t node-template:latest .
docker run --rm -it node-template:latest

Note: Notice that the Containerfile copy the binary from the current path.

2
  • I try to run first command but got error I have edited my question, can you please tell me what I am doing wrong?
    – go11li
    Commented Aug 29, 2023 at 12:53
  • You need to have the node-template binary in the current directory, and also if you are in a mac the image use ubuntu so will not work. You can build the binary in docker to have a compatible version.
    – pepoviola
    Commented Aug 29, 2023 at 13:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.