docker / for-linux

Docker Engine for Linux
https://docs.docker.com/engine/installation/
754 stars 85 forks source link

Different behavior between Mac and Ubuntu using alpine base image #538

Open cnasikas opened 5 years ago

cnasikas commented 5 years ago

Expected behavior

Similar behavior on both hosts. Specifically, matplotlib (numpy) library should be imported on both hosts.

Actual behavior

I try to import matplotlib (numpy) python module but an error is occurred. When I build and run the docker image on a mac with macOS mojave 10.14.2 everything is working fine. When I move the same image to Ubuntu 16.04.5 LTS server it fails. The image has as base image python:3-alpine that uses alpine linux.

I switch the base image to python:3 that uses debian stretch and everything is working as expected.

First I open an issue at matplotlib repo: https://github.com/matplotlib/matplotlib/issues/13059 but they said that it seems to be a docker issue.

Steps to reproduce the behavior

Dockerfile

FROM python:3-alpine
RUN apk --no-cache --update-cache add build-base wget freetype-dev libpng-dev openblas-dev

RUN pip3 install pipenv

RUN set -ex && mkdir /app
WORKDIR /app

COPY Pipfile .
COPY Pipfile.lock .

RUN set -ex && pipenv install

COPY . .

ENTRYPOINT ["/bin/sh"]

Build image & start docker container:

docker build -t my_image .
docker run -it my_image

Inside docker container:

pipenv run python

Python 3.7.2 (default, Dec 29 2018, 07:16:08)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot as plt

ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.7/site-packages/matplotlib/pyplot.py", line 32, in <module>
    import matplotlib.colorbar
  File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.7/site-packages/matplotlib/colorbar.py", line 28, in <module>
    import matplotlib.artist as martist
  File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.7/site-packages/matplotlib/artist.py", line 11, in <module>
    from .path import Path
  File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.7/site-packages/matplotlib/path.py", line 17, in <module>
    from . import _path, rcParams
ImportError: numpy.core.multiarray failed to import

Output of docker version:

macOS mojave 10.14.2:

Client: Docker Engine - Community
 Version:           18.09.0
 API version:       1.39
 Go version:        go1.10.4
 Git commit:        4d60db4
 Built:             Wed Nov  7 00:47:43 2018
 OS/Arch:           darwin/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.0
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.4
  Git commit:       4d60db4
  Built:            Wed Nov  7 00:55:00 2018
  OS/Arch:          linux/amd64
  Experimental:     true

Ubuntu 16.04.5 LTS:

Client:
 Version:           18.09.0
 API version:       1.39
 Go version:        go1.10.4
 Git commit:        4d60db4
 Built:             Wed Nov  7 00:48:57 2018
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.0
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.4
  Git commit:       4d60db4
  Built:            Wed Nov  7 00:16:44 2018
  OS/Arch:          linux/amd64
  Experimental:     false

Output of docker info:

macOS mojave 10.14.2:

Containers: 2
 Running: 0
 Paused: 0
 Stopped: 2
Images: 14
Server Version: 18.09.0
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 ipvlan macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 468a545b9edcd5932818eb9de8e72413e616e86e
runc version: 69663f0bd4b60df09991c08812a60108003fa340
init version: fec3683
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.125-linuxkit
Operating System: Docker for Mac
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.952GiB
Name: linuxkit-025000000001
ID: 3365:T6VU:CZY7:QUA4:WR7M:QJBB:XVNZ:KSTJ:2FOL:ZP3D:I4CC:CIYC
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 24
 Goroutines: 50
 System Time: 2018-12-30T14:38:36.567838304Z
 EventsListeners: 2
HTTP Proxy: gateway.docker.internal:3128
HTTPS Proxy: gateway.docker.internal:3129
Registry: https://index.docker.io/v1/
Labels:
Experimental: true
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine

Ubuntu 16.04.5 LTS:

Containers: 13
 Running: 7
 Paused: 0
 Stopped: 6
Images: 195
Server Version: 18.09.0
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 local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: c4446665cb9c30056f4998ed953e6d4ff22c7c39
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: fec3683
Security Options:
 apparmor
 seccomp
  Profile: default
Kernel Version: 4.4.0-130-generic
Operating System: Ubuntu 16.04.5 LTS
OSType: linux
Architecture: x86_64
CPUs: 24
Total Memory: 125.9GiB
Name: keftes
ID: G5JA:CHU3:EP7Z:MHYK:KIMR:LDSQ:IEPH:23XC:HKGQ:XTZU:CREX:FWYG
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: true
Product License: Community Engine

WARNING: No swap limit support

Additional environment details (AWS, VirtualBox, physical, etc.)

cnasikas commented 5 years ago

Reference: https://github.com/docker/for-linux/issues/133