tschm
tschm

Reputation: 2955

Anaconda Dockerimages

I am playing currently with Docker. Given the following simple Dockerfile:

# Set the base image to Ubuntu
FROM continuumio/miniconda3

# File Author / Maintainer
MAINTAINER Thomas Schmelzer

ADD . /pybank

WORKDIR /pybank

# build the environment
RUN conda install -y --file production.txt && conda clean --all --yes && nosetests

The resulting image is like 1.0 GB. In production.txt are pandas and nose. The folder for the pybank project is 230 KB within the running image. I am reading a lot about hacks trying to squezze the resulting images. Any ideas?

Here's the output of docker history:

IMAGE               CREATED              CREATED BY                                      SIZE                COMMENT
147465a83f44        21 seconds ago       /bin/sh -c conda install -y --file production   618.3 MB            
ac247a09a6b9        About a minute ago   /bin/sh -c #(nop) WORKDIR /pybank               0 B                 
ee7012dc6c28        About a minute ago   /bin/sh -c #(nop) ADD dir:9d26c17d067275f3836   62.45 kB            
2552d13402b6        3 hours ago          /bin/sh -c #(nop) MAINTAINER Thomas Schmelzer   0 B                 
2fd9d2e11210        4 days ago           /bin/sh -c #(nop) CMD ["/bin/bash"]             0 B                 
<missing>           4 days ago           /bin/sh -c #(nop) ENTRYPOINT ["/usr/bin/tini"   0 B                 
<missing>           4 days ago           /bin/sh -c #(nop) ENV PATH=/opt/conda/bin:/us   0 B                 
<missing>           4 days ago           /bin/sh -c apt-get install -y curl grep sed d   2.293 MB            
<missing>           4 days ago           /bin/sh -c echo 'export PATH=/opt/conda/bin:$   133 MB              
<missing>           4 days ago           /bin/sh -c apt-get update --fix-missing && ap   195 MB              
<missing>           4 days ago           /bin/sh -c #(nop) ENV LANG=C.UTF-8 LC_ALL=C.U   0 B                 
<missing>           4 days ago           /bin/sh -c #(nop) MAINTAINER Kamil Kwiek <kam   0 B                 
<missing>           3 weeks ago          /bin/sh -c #(nop) CMD ["/bin/bash"]             0 B                 
<missing>           3 weeks ago          /bin/sh -c #(nop) ADD file:76679eeb94129df23c   125.1 MB     

thomas

Upvotes: 0

Views: 283

Answers (1)

CMPS
CMPS

Reputation: 7769

This solution works if you don't care about the image history:

Create a container from the image

docker run --name my_container -it my_image:my_tag my_command

Export the container

docker export my_container > my_container.tar.gz

Import the container as an image:

cat my_container.tar.gz | docker import - my_small_image:my_tag

Check the new image entry

docker images

Upvotes: 1

Related Questions