A Python Docker image

Submitted by code_admin on Thu, 04/11/2019 - 15:52

I am learning how to make a utility image which can accept python commands

  1. FROM alpine:3.8
  2.  
  3. RUN apk add --no-cache curl python python3 gcc python3-dev linux-headers build-base libffi-dev && \
  4.     python3 -m ensurepip && \
  5.     rm -r /usr/lib/python*/ensurepip && \
  6.     pip3 install --upgrade pip setuptools && \
  7.     pip3 install requests && \
  8.     if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi && \
  9.     if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi && \
  10.     rm -r /root/.cache
  11.  
  12.  
  13. #Features to add
  14. # Connect test endpoint to new container
  15. # If main service dosen't exist create it
  16. # Add new container as upstream to main service
  17. # Move main service so it is 100% pointing at new service
  18.  
  19.  
  20. ENTRYPOINT ["/usr/bin/python3"]

docker build . -t metcarob/tmp_image:localbuild

Interactive run

docker run -it metcarob/tmp_image:localbuild

Command line input

printf "print('aa')\nprint('bb')\n" | docker run -i metcarob/tmp_image:localbuild

Tags

RJM Article Type
Work Notes