Skip to content

Instantly share code, notes, and snippets.

@timroster
Created March 25, 2020 13:10
Show Gist options
  • Save timroster/efa6c4c55068bf9e7361bb51f76e4081 to your computer and use it in GitHub Desktop.
Save timroster/efa6c4c55068bf9e7361bb51f76e4081 to your computer and use it in GitHub Desktop.

Some Docker examples

running a container image with simple command:

docker run centos echo "hello world"
docker run -it centos bash

create an simple flask app:

echo 'from flask import Flask

app = Flask(__name__)

@app.route("/")
def hello():
    return "hello world!"

if __name__ == "__main__":
    app.run(host="0.0.0.0")' > app.py

Create a Dockerfile to build it

echo 'FROM quay.io/bitnami/python
RUN pip install flask
CMD ["python","app.py"]
COPY app.py /app.py' > Dockerfile

Build the image

docker build -t myapp:v1 .

Run the image

docker run -it -p 5000:5000 myapp:v1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment