Search code examples
dockercurldockerfileshvscode-devcontainer

Docker Run: How to run .sh script from url?


I am new to Docker and trying to install NordVpn inside Docker Container by running the .sh script listed in their documentation.

Below is my dockerfile and the error I am getting when running this from a vscode devcontainer

FROM mcr.microsoft.com/devcontainers/dotnet:0-7.0

# install redis
# https://redis.io/docs/getting-started/installation/install-redis-on-linux/
RUN sudo apt install lsb-release curl gpg && \
    curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg && \
    echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list && \
    sudo apt-get update && sudo apt-get install redis -y

#install nordvpn
RUN sh <(curl -sSf https://downloads.nordcdn.com/apps/linux/install.sh)

Error

> [dev_container_auto_added_stage_label 3/3] RUN sh <(curl -sSf https://downloads.nordcdn.com/apps/linux/install.sh):
0.203 /bin/sh: 1: Syntax error: "(" unexpected

I have also tried removing the parens. It complains about "no such file" however this file can be downloaded.

sh < curl -sSf https://downloads.nordcdn.com/apps/linux/install.sh

> [dev_container_auto_added_stage_label 3/3] RUN sh < curl -sSf https://downloads.nordcdn.com/apps/linux/install.sh:
0.245 /bin/sh: 1: cannot open curl: No such file

I would expect this to run the sh script as if I pasted this line into the terminal.


Solution

  • Try replacing the last line of your Dockerfile:

    RUN sh <(curl -sSf https://downloads.nordcdn.com/apps/linux/install.sh)
    

    with the following:

    RUN curl -sSf https://downloads.nordcdn.com/apps/linux/install.sh | sh
    

    This will pipe the remote install.sh script to the shell invoked within the Docker container.