I am trying to build a docker image from a book by Dr. Yves J. Hilpisch, “Python for Finance” 2nd edition page 46.
This book is from O’Reilly and the odds are good that you, dear reader, have access to it online.
In any case, access to this book is not necessary to read this thread. It should be enough to see the files and commands I am using which I provide here:
install.sh:
#!/bin/bash
#
# Script to Install
# Linux System Tools and
# Basic Python Components
#
# Python for Finance, 2nd ed.
# (c) Dr. Yves J. Hilpisch
#
# GENERAL LINUX
apt-get update # updates the package index cache
apt-get upgrade -y # updates packages
# installs system tools
apt-get install -y bzip2 gcc git htop screen vim wget
apt-get upgrade -y bash # upgrades bash if necessary
apt-get clean # cleans up the package index cache
# INSTALL MINICONDA
# downloads Miniconda
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O Miniconda.sh
bash Miniconda.sh -b # installs it
rm -rf Miniconda.sh # removes the installer
export PATH="/root/miniconda3/bin:$PATH" # prepends the new path
# INSTALL PYTHON LIBRARIES
conda update -y conda python # updates conda & Python (if required)
conda install -y pandas # installs pandas
conda install -y ipython # installs IPython shell
Dockerfile
#
# Building a Docker Image with
# the Latest Ubuntu Version and
# Basic Python Install
#
# Python for Finance, 2nd ed.
# (c) Dr. Yves J. Hilpisch
#
# latest Ubuntu version
FROM ubuntu:latest
# information about maintainer
MAINTAINER yves
# add the bash script
ADD install.sh /
# change rights for the script
RUN chmod u+x /install.sh
# run the bash script
RUN /install.sh
# prepend the new path
ENV PATH /root/miniconda3/bin:$PATH
# execute IPython when container is run
CMD ["ipython"]
Below is my terminal session in Fedora version 41:
(base) wiking@walhalla:~/Docker$ sudo docker build -t py4fi:basic .
Place your right index finger on the fingerprint reader
[+] Building 674.3s (8/8) FINISHED docker:default
=> [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 651B 0.0s
=> WARN: MaintainerDeprecated: Maintainer instruction is deprecated in favor of using label (line 14) 0.1s
=> [internal] load metadata for docker.io/library/ubuntu:latest 0.6s
=> [internal] load .dockerignore 0.1s
=> => transferring context: 2B 0.0s
=> [internal] load build context 0.1s
=> => transferring context: 146B 0.0s
=> [1/4] FROM docker.io/library/ubuntu:latest@sha256:72297848456d5d37d1262630108ab308d3e9ec7ed1c3286a32fe09856619a782 0.0s
=> CACHED [2/4] ADD install.sh / 0.0s
=> CACHED [3/4] RUN chmod u+x /install.sh 0.0s
=> ERROR [4/4] RUN /install.sh 673.3s
------
> [4/4] RUN /install.sh:
56.45 Ign:1 http://security.ubuntu.com/ubuntu noble-security InRelease
56.45 Ign:2 http://archive.ubuntu.com/ubuntu noble InRelease
112.5 Ign:3 http://archive.ubuntu.com/ubuntu noble-updates InRelease
113.5 Ign:1 http://security.ubuntu.com/ubuntu noble-security InRelease
168.6 Ign:4 http://archive.ubuntu.com/ubuntu noble-backports InRelease
171.6 Ign:1 http://security.ubuntu.com/ubuntu noble-security InRelease
224.6 Ign:2 http://archive.ubuntu.com/ubuntu noble InRelease
231.6 Err:1 http://security.ubuntu.com/ubuntu noble-security InRelease
231.6 Temporary failure resolving 'security.ubuntu.com'
280.7 Ign:3 http://archive.ubuntu.com/ubuntu noble-updates InRelease
336.7 Ign:4 http://archive.ubuntu.com/ubuntu noble-backports InRelease
392.8 Ign:2 http://archive.ubuntu.com/ubuntu noble InRelease
448.8 Ign:3 http://archive.ubuntu.com/ubuntu noble-updates InRelease
504.9 Ign:4 http://archive.ubuntu.com/ubuntu noble-backports InRelease
561.0 Err:2 http://archive.ubuntu.com/ubuntu noble InRelease
561.0 Temporary failure resolving 'archive.ubuntu.com'
617.0 Err:3 http://archive.ubuntu.com/ubuntu noble-updates InRelease
617.0 Temporary failure resolving 'archive.ubuntu.com'
673.1 Err:4 http://archive.ubuntu.com/ubuntu noble-backports InRelease
673.1 Temporary failure resolving 'archive.ubuntu.com'
673.1 Reading package lists...
673.1 W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/noble/InRelease Temporary failure resolving 'archive.ubuntu.com'
673.1 W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/noble-updates/InRelease Temporary failure resolving 'archive.ubuntu.com'
673.1 W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/noble-backports/InRelease Temporary failure resolving 'archive.ubuntu.com'
673.1 W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/noble-security/InRelease Temporary failure resolving 'security.ubuntu.com'
673.1 W: Some index files failed to download. They have been ignored, or old ones used instead.
673.1 Reading package lists...
673.1 Building dependency tree...
673.1 Reading state information...
673.1 Calculating upgrade...
673.1 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
673.1 Reading package lists...
673.2 Building dependency tree...
673.2 Reading state information...
673.2 Package bzip2 is not available, but is referred to by another package.
673.2 This may mean that the package is missing, has been obsoleted, or
673.2 is only available from another source
673.2
673.2 E: Package 'bzip2' has no installation candidate
673.2 E: Unable to locate package gcc
673.2 E: Unable to locate package git
673.2 E: Unable to locate package htop
673.2 E: Unable to locate package screen
673.2 E: Unable to locate package vim
673.2 E: Unable to locate package wget
673.2 Reading package lists...
673.2 Building dependency tree...
673.2 Reading state information...
673.2 bash is already the newest version (5.2.21-2ubuntu4).
673.2 Calculating upgrade...
673.2 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
673.2 /install.sh: line 20: wget: command not found
673.2 bash: Miniconda.sh: No such file or directory
673.2 /install.sh: line 26: conda: command not found
673.2 /install.sh: line 27: conda: command not found
673.2 /install.sh: line 28: conda: command not found
------
2 warnings found (use docker --debug to expand):
- MaintainerDeprecated: Maintainer instruction is deprecated in favor of using label (line 14)
- LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format (line 26)
Dockerfile:23
--------------------
21 |
22 | # run the bash script
23 | >>> RUN /install.sh
24 |
25 | # prepend the new path
--------------------
ERROR: failed to solve: process "/bin/sh -c /install.sh" did not complete successfully: exit code: 127
I installed docker on Fedora using sudo dnf install docker-cli containerd
Here are the versions of the packages that are installed:
(base) wiking@walhalla:~$ dnf list docker*
Updating and loading repositories:
Repositories loaded.
Installed packages
docker-buildx.x86_64 0.18.0-1.fc41 updates
docker-cli.x86_64 27.3.1-2.fc41 fedora
Available packages
docker-compose.x86_64 2.30.3-1.fc41 updates
docker-compose-switch.x86_64 1.0.5-1.fc41 fedora
docker-distribution.x86_64 2.8.1-6.gitb5ca020.fc41 fedora
(base) wiking@walhalla:~$ dnf list container*
Updating and loading repositories:
Repositories loaded.
Installed packages
container-selinux.noarch 4:2.235.0-2.fc41 updates
containerd.x86_64 1.7.25-1.fc41 updates
containers-common.noarch 5:0.62.0-1.fc41 updates
containers-common-extra.noarch 5:0.62.0-1.fc41 updates
Available packages
container-storage-setup.noarch 0.11.0-16.dev.git413b408.fc41 fedora
containernetworking-plugins.x86_64 1.6.2-1.fc41 updates
What am I doing wrong?