Giter Site home page Giter Site logo

docker-python-template's Introduction

Docker Python Template

Prerequisites

  1. [For Windows users] To install Docker Desktop, you'll need Windows 10 Pro or Enterprise version 15063.
  2. Install Docker
  • for Mac

  • for Linux

  • for Windows

  • Important things to note:

    • You will be prompted to create a DockerHub account. Follow the instructions in order to download Docker
    • Follow the installation prompts (go with the default options) until you have successfully started Docker
    • [Windows users] When prompted to enable Hyper-V and Containers features, click 'Ok' and let computer restart again.
    • You may have to restart your computer 2-3 times.
  1. Start Docker on your desktop (Note: Wait for Docker to complete startup before running the subsequent commands. You'll know when startup is completed when the docker icon in your taskbar stops animating)

Setup

# build
docker build . -t my-project

# run container
docker run -it -v $(pwd):/code -p 8888:8888 my-project bash
# note: -p 8888:8888 maps port 8888 to your host machine and is needed for jupyter notebooks
# note: -v $(pwd):/code mounts your current working directory (presumably your project directory) and makes any changes instantly available in the running container

# run unit tests
nosetests

# run unit tests in watch mode and color output
nosetests --with-watch --rednose --nologcapture

If you want to run 2 long-lived commands/processes in the same container (e.g. run jupyter notebook and nosetests at the same time), you can start a second process in a running container by doing the following:

# see list of running containers
docker ps

# start a bash shell in a running container
docker exec -it <container-id> bash

# run the second command, for example, if you want to start a jupyter notebook:
jupyter notebook --ip 0.0.0.0 --no-browser --allow-root

Configure your IDE

  1. install dependencies on host (because your IDE can't use the dependencies inside the Docker container): bin/install_deps_locally.sh
  2. tell your IDE the path to the Python virtual environment on your host
  3. restart your IDE (you may have to give it a minute or 2)
  4. start using intellisense!

docker-python-template's People

Contributors

davidtan-tw avatar davified avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.