Created
December 29, 2021 05:11
-
-
Save hmboyd/99af7e929165dce672e4d14a6a0f6ca6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Dockerfile Django app | |
```docker | |
FROM python:3.8 | |
WORKDIR /app | |
RUN python3 -m venv env | |
ENV PYTHONDONTWRITEBYTECODE=1 | |
ENV PYTHONUNBUFFERED=1 | |
COPY requirements.txt . | |
RUN . env/bin/activate && pip3 install -r requirements.txt | |
COPY . . | |
CMD . env/bin/activate && gunicorn --bind 0.0.0.0:$PORT oc_lettings_site.wsgi | |
``` | |
# Docker shell commands | |
Construction de l'image Docker puis lancement du conteneur | |
```shell | |
$ sudo docker build -t <tag-name> . | |
$ sudo docker run -p 8001:8000 <tag-name> | |
``` | |
Pousser l'image Docker vers le Docker Hub | |
```shell | |
$ sudo docker build -t virgindocker75/<repo-name>:<tag> . | |
$ sudo docker login | |
$ sudo docker push virgindocker75/<repo-name>:<tag> | |
``` | |
Lister les images Docker en cours d'execution | |
```shell | |
$ sudo docker ps | |
``` | |
Execution d'une commande shell au sein du conteneur | |
```shell | |
$ sudo docker exec -it <container-id-or-name> pytest | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment