I'm in the process of creating a Docker image for our Substrate-node, and I used that following method to accomplish it.

# This is an example build stage for the node template. Here we create the binary in a temporary image.

# This is a base image to build substrate nodes
FROM docker.io/paritytech/ci-linux:production as builder

WORKDIR /node-template
COPY . .
RUN rm -rf /usr/local/rustup /usr/local/cargo && \
    curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain none && \
    rustup show && \
    cargo build --release

# This is the 2nd stage: a very small image where we copy the binary."
FROM docker.io/library/ubuntu:22.04
LABEL description="Multistage Docker image for Substrate Node Template" \
  image.type="builder" \
  image.authors="[email protected]" \
  image.vendor="Substrate Developer Hub" \
  image.description="Multistage Docker image for Substrate Node Template" \
  image.source="https://github.com/substrate-developer-hub/substrate-node-template" \

# Copy the node binary.
COPY --from=builder /node-template/target/release/node-template /usr/local/bin

RUN useradd -m -u 1000 -U -s /bin/sh -d /node-dev node-dev && \
  mkdir -p /chain-data /node-dev/.local/share && \
  chown -R node-dev:node-dev /chain-data && \
  ln -s /chain-data /node-dev/.local/share/node-template && \
  # unclutter and minimize the attack surface
  rm -rf /usr/bin /usr/sbin && \
  # check if executable works in this container
  /usr/local/bin/node-template --version

USER node-dev

EXPOSE 30333 9933 9944 9615
VOLUME ["/chain-data"]

ENTRYPOINT ["/usr/local/bin/node-template"]

And I got the image successfully. So I run it using this command.

docker run -it -p 9944:9944 wolfmorgan/substrate-node

Now I got Running JSON-RPC server: addr=, but I want to get Running JSON-RPC WS server: addr=, allowed origins=["*"]

How can I build a docker image to get this? Any advice would be appreciated.

Thank you in advance.

  • I tried ENTRYPOINT ["/usr/local/bin/node-template", "--dev", "--ws-external", but got --ws-external arg not found
    – Alan Ma
    Sep 7, 2023 at 13:49
  • Try --unsafe-ws-external
    – forgetso
    Sep 7, 2023 at 15:01
  • I got error: unexpected argument '--unsafe-ws-external' found
    – Alan Ma
    Sep 7, 2023 at 16:59
  • So I tried --unsafe-rpc-external instead of --unsafe-ws-external. But I couldn't get the result what I wanted - Running JSON-RPC WS server: addr=, allowed origins=["*"]. Just I got Running JSON-RPC server: addr=
    – Alan Ma
    Sep 7, 2023 at 17:31
  • Hi @AlanMa, running node-template --dev should start the rpc server listening in, from which tag are you compiling the node?
    – pepoviola
    Sep 8, 2023 at 13:12

1 Answer 1


You need to add --rpc-cors=all to achieve allowed origins=["*"].

Here is the explanation for the flag:

$ substrate --help
      --rpc-cors <ORIGINS>
          Specify browser Origins allowed to access the HTTP & WS RPC servers.

          A comma-separated list of origins (protocol://domain or special `null` value). 
          Value of `all` will disable origin validation. 
          Default is to allow localhost and <https://polkadot.js.org> origins. 
          When running in --dev mode the default is to allow all origins.
  • Thanks for your answer, @btwiuse. But I got already allowed origins=["*"]. Like this. Running JSON-RPC server: addr=, allowed origins=["*"]. But I want to run JSON-RPC WS server instead of JSON-RPC server. Like this Running JSON-RPC WS server: addr=, allowed origins=["*"]
    – Alan Ma
    Sep 14, 2023 at 18:07
  • @AlanMa It is already a WS server regardless of the log message
    – btwiuse
    Sep 15, 2023 at 4:19
  • But I couldn't connect with the substrate node using ws:// @btwiuse.
    – Alan Ma
    Sep 15, 2023 at 7:48
  • Error Connecting to Substrate Connection to websocket 'ws://' failed.
    – Alan Ma
    Sep 15, 2023 at 7:55

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.