0

Trying to upgrade Node and NPM in Dockerfile for a machine that has Internet restrictions - can anyone help?

Here is what I tried:

  1. I downloaded the latest node on a machine with no restrictions to the Internet.
  2. Copied the binary to the machine with Internet restrictions.
  3. In the Dockerfile, I copy the file in to the image and then I un-tar the file.
FROM docker-mirror:443/dotnet/sdk:6.0-jammy

COPY ../node_update_src/node-v18.17.0-linux-x64.tar.xz /home/node_src/
RUN tar --strip-components 1 -xzf /home/node_src/node-v4.2.1-linux-x64.tar.gz  --directory /usr/local

It does not work - any suggestions please?

PKCS12
  • 407
  • 15
  • 41
  • did your solution work? – MeerArtefakt Aug 01 '23 at 11:45
  • Some time ago I had a same use case, I was able to work with `save` and `load` here [How to copy Docker images from one host to another without using a repository](https://stackoverflow.com/questions/23935141/how-to-copy-docker-images-from-one-host-to-another-without-using-a-repository) – MeerArtefakt Aug 01 '23 at 11:48
  • @PKCS12 did my answer work for you? – Alez Aug 08 '23 at 19:49

1 Answers1

1

Another way is to create a Docker image on the "online" machine in the standard way, with a Dockerfile like:

FROM mcr.microsoft.com/dotnet/sdk:6.0-jammy
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && apt-get install -y nodejs

then create the docker image:

docker build node-image .

save the image on the filesystem:

docker save -o <path-tar-output-file> node-image

and finally move it on the offline machine and load it with:

mv <path-tar-output-file> <offline-machine>/<destination-tar-file-path>
docker load -i <destination-tar-file-path>

You can also automate this process with a simple bash script.

Alez
  • 1,913
  • 3
  • 18
  • 22