- –detach表示後臺運行
- –publish 將程序的端口運行在本地主機的另一個端口
- –name 起名字
app.py
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")'
Dockerfile
FROM python:3.6.1-alpine
RUN pip install flask
CMD ["python","app.py"]
COPY app.py /app.py
docker container run -t ubuntu top
docker container exec -it 1db343e6dacd bash
docker container run --detach --publish 8080:80 --name nginx nginx
docker container run --detach --publish 8081:27017 --name mongo mongo:3.4
docker container ls
docker container stop [container id]
docker system prune
docker image build -t python-hello-world dir
docker run -p 5001:5000 -d python-hello-world
docker image ls
docker container logs [container id]
docker login
docker tag python-hello-world [dockerhub username]/python-hello-world
docker push [dockerhub username]/python-hello-world
docker image build -t [dockerhub username]/python-hello-world
docker push [dockerhub username]/python-hello-world
docker image history python-hello-world