Docker-Hub-frolvlad / docker-alpine-python2

The smallest Docker image with Python 2.7 (~50MB)

Home Page:https://hub.docker.com/r/frolvlad/alpine-python2/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to run python app with your image

agentfitz opened this issue · comments

Hello,

I am completely new to python. I am looking to setup a simple python environment so I can learn python by creating and editing a python file on a volume mapped file within my file system (or in a volume mapped directory into the python container) and running that file in a browser.

I was able to get your Docker image to print the 'hello world' example in the command line, but what are the necessary steps to take to actually run a hello-world file from a text editor environment so I can actually start to build an application.

Would you be able to add some of those instructions to your docker hub page? For example:

Step 1) docker run frolvlad/alpine-python2
Step 2) ssh into container and create your python file in the /var/www directory
Step 3) access through localhost

Thanks for your guidance and thanks for the light weight python container!

I am not sure my image is good for Python learning because Docker adds another layer of complexity...

Anyway, I suggest you just use an interactive mode to get into the shell with python:

$ docker run -it --rm frolvlad/alpine-python2 sh
# python
>>> print "Hello!"
Hello!

The used Docker options are:

  • -i option enables stdin;
  • -t option enables TTY mode;
  • --rm option marks the container for removing once you stop it.

You may also choose to mount your local folder somewhere into the container, then you need to pass --volume /local/path:/path/inside/container to docker run command.

If you want to be able to access a TCP port (e.g. your web application), you also need to pass --publish "local-port":"container-port" to docker run.

Good luck.

Got you. Well, I am already somewhat comfortable with Docker. To me, one of the major benefits of using something like Docker is so the user doesn't have to mess with configuring a python environment, and can just start using it right away to build an application. Maybe that's not how you see it?

Anyhow, thanks for your response, I'll look into what you suggested.