Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I install curl inside my container?

Tags:

docker

curl

I have the following Dockerfile

FROM jupyter/scipy-notebook

#RUN apt-get update && apt-get install -y curl

RUN pip install mlflow

RUN pip install sklearn

RUN apt-get update && apt-get install -y curl

When I do

docker build -t mycontainer .

I get

Step 4/4 : RUN apt-get update && apt-get install -y curl
 ---> Running in 5defd9816a22
Reading package lists...
E: List directory /var/lib/apt/lists/partial is missing. - Acquire (13: Permission denied)
The command '/bin/bash -o pipefail -c apt-get update && apt-get install -y curl' returned a non-zero code: 100

I suspect it is something related with not running as a root? So how can I install curl in my container from the Dockerfile?

EDIT: I applied the answer that I was given. Unfortunately it did not work

Step 4/7 : USER root
 ---> Running in aa6a1b7a023f
Removing intermediate container aa6a1b7a023f
 ---> 59e87b9598b2
Step 5/7 : RUN apt-get update && apt-get install -y curl
 ---> Running in 4440ce61ebc6
Err:1 http://security.ubuntu.com/ubuntu focal-security InRelease
  Temporary failure resolving 'security.ubuntu.com'
Err:2 http://archive.ubuntu.com/ubuntu focal InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Reading package lists...
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-updates/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-backports/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/focal-security/InRelease  Temporary failure resolving 'security.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package curl
The command '/bin/bash -o pipefail -c apt-get update && apt-get install -y curl' returned a non-zero code: 100

EDIT2: I tried it in a different network setup and it worked.

like image 738
KansaiRobot Avatar asked Oct 13 '25 07:10

KansaiRobot


1 Answers

Try to install it with root as it done in official jupyter/scipy-notebook Dockerfile and set it back to $NB_UID: (see user declaration in official base docker image)

USER root
# Install packages you need:
RUN apt-get update && apt-get install -y curl
# Switch back to jovyan to avoid accidental container runs as root
USER $NB_UID

Here is the hierarchy of base docker images used by jupyter/scipy-notebook:

jupyter/base-notebook -> jupyter/minimal-notebook -> jupyter/scipy-notebook

like image 88
1c0DevPi Avatar answered Oct 14 '25 22:10

1c0DevPi