I suggest using the official python
image instead. As a result, your Dockerfile will now become:
FROM python: 3
WORKDIR / testing
COPY. / requirements.txt / testing / requirements.txt
RUN pip install--no - cache - dir - r requirements.txt
...etc...
Now re: Angular/Node. You have two options from here: 1) Install Angular/Node on the Python image; or 2) Use Docker's multi-stage build feature so you build the Angular and Python-specific images before merging them together. Option 2 is recommended but it would take some work. It would probably look like this:
FROM node: 8 as node
# Angular - specific build
FROM python: 3 as python
# Python - specific build
# Then copy your data from the Angular image to the Python one:
COPY--from = node / usr / src / app / dist / angular - docker / usr / src / app
Pip Example: Installing Spacy with pip # Python has an official image. Alpine and slim are the small versions FROM python:3.7.7-slim-stretch #Installation directions found at https://spacy.io/usage --no-cache-dir allows one to save space in the final image RUN pip install --no-cache-dir -U spacy # Copies script.py file in my current directory to root in the container COPY script.py / , Compare Image Sizes Check your Docker hub profile and click on your spacy image. You will see a conda and pip tag under tags. pip is much smaller and you likely noticed it was faster to build. ,Check your Docker hub profile and click on your spacy image. You will see a conda and pip tag under tags. pip is much smaller and you likely noticed it was faster to build.,Installing Python Packages In Your Docker Container Workshop Video pip (and a Linux package manger) vs anaconda Case Study: Spacy
from spacy.lang.en import English # Create the nlp object nlp = English() # Created by processing a string of text with the nlp object doc = nlp("Hello world!") # Iterate over tokens in a Doc for token in doc: print(token.text)
# Python has an official image.Alpine and slim are the small versions
FROM python: 3.7 .7 - slim - stretch
#Installation directions found at https: //spacy.io/usage --no-cache-dir allows one to save space in the final image
RUN pip install--no - cache - dir - U spacy
# Copies script.py file in my current directory to root in the container
COPY script.py /
docker build - t dockerhub_username / spacy: pip. docker push dockerhub_username / spacy: pip
# Conda has an official base image.miniconda3 is the smaller python3 based on Debian stretch
FROM conda / miniconda3
RUN conda install - c conda - forge spacy
COPY script.py /
docker build - t dockerhub_username / spacy: conda. docker push dockerhub_username / spacy: conda
bsub - G group_name - Is - q general - interactive - a 'docker(docker_hub_username/spacy:pip)'
python3 / script.py
bsub - G group_name - Is - q general - interactive - a 'docker(docker_hub_username/spacy:conda)'
python3 / script.py
Install the Docker repository. Type the following, hitting enter after each line or simply copy the contents starting with [docker] into /etc/yum.repos.d/docker.repo: ,Type the following, hitting enter after each line or simply copy the contents starting with [docker] into /etc/yum.repos.d/docker.repo: ,For POWER9: Install the Docker repository. Type the following, hitting enter after each line or simply copy the contents starting with [docker] into /etc/yum.repos.d/docker.repo: # cat > /etc/yum.repos.d/docker.repo << EOF [docker] name=Docker baseurl=http://ftp.unicamp.br/pub/ppc64el/rhel/7/docker-ppc64el/ enabled=1 gpgcheck=0 EOF Install the Docker package: # yum install docker-ce ,All components, aside from the SSE running on Windows, run on Linux in a Docker container. For these container components, Docker components must be installed and running on each server prior to continuing with the Video Analytics component installations.
Python 2:
# subscription - manager repos--enable rhel - server - rhscl - 7 - rpms
# yum install python27 - python - pip - y
# scl enable python27 bash
# pip install--upgrade pip
Python 3:
# subscription - manager repos--enable rhel - server - rhscl - 7 - rpms
# yum - y install rh - python36
# scl enable rh - python36 bash
# pip3 install--upgrade pip
# yum install - y yum - utils\
device - mapper - persistent - data\
lvm2
# yum - config - manager\
--add - repo\
https: //download.docker.com/linux/centos/docker-ce.repo
# yum install docker - ce docker - ce - cli containerd.io
Type the following, hitting enter after each line or simply copy the contents starting with [docker] into /etc/yum.repos.d/docker.repo:
# cat > /etc/yum.repos.d / docker.repo << EOF[docker] name = Docker baseurl = http: //ftp.unicamp.br/pub/ppc64el/rhel/7/docker-ppc64el/ enabled=1 gpgcheck = 0 EOF
# yum install docker - ce
# systemctl start docker
# docker run--rm hello - world
You should see output similar to the following:
Unable to find image 'hello-world:latest'
locally latest: Pulling from library / hello - world
1 b930d010525: Pull complete
Digest: sha256: 2557e3 c07ed1e38f26e389462d03ed943586f744621577a99efb77324b0fe535
Status: Downloaded newer image
for hello - world: latest Hello from Docker!
Video Analytics message shows that your installation appears to be working correctly.
To generate Video Analytics message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world"
image from the Docker Hub.(amd64)
3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal.
To
try something more ambitious, you can run an Ubuntu container with:
$ docker run - it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https: //hub.docker.com/
For more examples and ideas, visit:
https: //docs.docker.com/get-started/
Python 2:
# pip install docker - compose
Python 3:
# pip3 install docker - compose
# docker - compose version docker - compose version 1.23 .2, build 1110 ad0 docker - py version: 3.7 .0 CPython version: 2.7 .13 OpenSSL version: OpenSSL 1.0 .1 e - fips 11 Feb 2013
In this post, we will see How To Install Python Packages in a Docker Container. When any Python packages is not correctly installed or not reachable from Docker , we are unable to import the packages and see the below error –,How To Install Python Packages in a Docker Container ?,Now let’s see the different ways that we can install a Python package in a Docker container.,Suppose you have 10 Python packages installed in your computer\laptop. However a Docker container would not be “aware” of these installed packages. This is because a Docker container is isolated .
In this post, we will see How To Install Python Packages in a Docker Container. When any Python packages is not correctly installed or not reachable from Docker , we are unable to import the packages and see the below error –
ImportError: No module named '<PACKAGE_NAME>'
FROM docker - dev.artifactory.company.com / centos: 7.3 .1611
**
** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** *
Existing commands in the Dockerfile **
** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** *
RUN yum install - y krb5 - devel
RUN yum install - y python - devel
RUN yum install - y krb5 - workstation
RUN yum install - y python - setuptools
RUN yum install - y python - pip
This will open the container console and then you can execute the install command like a regular terminal console –
pip install numpy
Adding dns as suggested here - https://stackoverflow.com/questions/28668180/cant-install-pip-packages-inside-a-docker-container-with-ubuntu/41989423#41989423 is not helping .,I just had the same error and was able to solve it by adding lines to the Dockerfile file (after the initial FROM line).,1: Orientation 2: Containers 3: Services 4: Swarms 5: Stacks 6: Deploy your app Prerequisites Install Docker version 1.13 or higher. Read the orientation in Part 1. Give your environment...,I have setup docker on my fresh ubuntu 16.04.02 setup. successfully run the “docker run hello-world” and “ubuntu bash”. when I try to builf the python image i get -
The proposed solution does not work for my system:
cat / etc / os - release
NAME = "Ubuntu"
VERSION = "16.04.3 LTS (Xenial Xerus)"
ID = ubuntu
ID_LIKE = debian
PRETTY_NAME = "Ubuntu 16.04.3 LTS"
VERSION_ID = "16.04"
HOME_URL = "http://www.ubuntu.com/"
SUPPORT_URL = "http://help.ubuntu.com/"
BUG_REPORT_URL = "http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME = xenial
UBUNTU_CODENAME = xenial
Kernel info:
uname - a
Linux c3p0 4.10 .0 - 28 - generic #32~16.04.2-Ubuntu SMP Thu Jul 20 10:19:48 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Docker details:
docker--version
Docker version 17.12 .0 - ce, build c97c6d6
docker info
Containers: 6
Running: 0
Paused: 0
Stopped: 6
Images: 16
Server Version: 17.12 .0 - ce
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json - file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json - file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker - init
containerd version: 89623 f28b87a6004d4b785663257362d1658a729
runc version: b2567b37d7b75eb4cf325b77297b140ea686ce8f
init version: 949e6 fa
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 4.10 .0 - 28 - generic
Operating System: Ubuntu 16.04 .3 LTS
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 3.857 GiB
Name: c3p0
ID: ID7G: ZMDK: 2 VKT: HCIN: 6 MMT: 7 PI5: Z7DV: JJL2: QOFU: PZ3T: MQQ4: 3 YBO
Docker Root Dir: /var/lib / docker
Debug Mode(client): false
Debug Mode(server): false
Registry: https: //index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0 .0 .0 / 8
Live Restore Enabled: false
WARNING: No swap limit support
Dockerfile:
# Use an official Python runtime as a parent image
FROM python: 2.7 - slim
ENV http_proxy http: //proxy-chain.xxx.com:911/
ENV https_proxy http: //proxy-chain.xxx.com:912/
# Set the working directory to / app
WORKDIR / app
# Copy the current directory contents into the container at / app
ADD. / app
# Install any needed packages specified in requirements.txt
RUN pip install--trusted - host pypi.python.org - r requirements.txt
# Make port 80 available to the world outside this container
EXPOSE 80
# Define environment variable
ENV NAME World
# Run app.py when the container launches
CMD["python", "app.py"]
requirements.txt file:
Flask Redis
I suggest using the official python anycodings_docker image instead. As a result, your anycodings_docker Dockerfile will now become:,by using it in this way, you are anycodings_docker specifying the version of python in anycodings_docker which you want to search for those anycodings_docker packages.,RUN python3.6 -m pip install --upgrade anycodings_docker pip \ && python3.6 -m pip anycodings_docker install -r requirements.txt,Basically, I have not mentioned any version anycodings_python in "requirements.txt". I guess it should anycodings_python take the latest available and compatible anycodings_python version of that package. But for every anycodings_python package same issue I am getting.
I am trying to create an docker image with anycodings_python ubutu 16.04 as base. I want to install few anycodings_python python packages like pandas, flask etc. I anycodings_python have kept all packages in anycodings_python "requirements.txt". But when I am trying to anycodings_python build image, I am getting
Could not find a version that satisfies the requirement requests(from - r requirements.txt(line 1))(from versions: )
No matching distribution found
for requests(from - r requirements.txt(line 1))
My DockerFile is as follows.
FROM ubuntu: 16.04
RUN apt - get update - y && \
apt - get install - y python3 - pip python3 - dev build - essential cmake pkg - config libx11 - dev libatlas - base - dev
# We copy just the requirements.txt first to leverage Docker cache
COPY. / requirements.txt / testing / requirements.txt
WORKDIR / testing
RUN pip3 install - r requirements.txt
and requirements.txt is.
pandas requests PyMySQL Flask Flask - Cors Pillow face - recognition Flask - SocketIO
I suggest using the official python anycodings_docker image instead. As a result, your anycodings_docker Dockerfile will now become:
FROM python: 3
WORKDIR / testing
COPY. / requirements.txt / testing / requirements.txt
RUN pip install--no - cache - dir - r requirements.txt
...etc...
Now re: Angular/Node. You have two anycodings_docker options from here: 1) Install anycodings_docker Angular/Node on the Python image; or 2) anycodings_docker Use Docker's multi-stage build feature anycodings_docker so you build the Angular and anycodings_docker Python-specific images before merging anycodings_docker them together. Option 2 is recommended anycodings_docker but it would take some work. It would anycodings_docker probably look like this:
FROM node: 8 as node
# Angular - specific build
FROM python: 3 as python
# Python - specific build
# Then copy your data from the Angular image to the Python one:
COPY--from = node / usr / src / app / dist / angular - docker / usr / src / app