(this is too complex, disconsider. It's actually easier to use a temporary
Dockerfile
for a dev container)
(This examples imply opinionated workflows or local configurations which may not apply to your case. Good projects have good documentation. ALWAYS refer to them for official positions of the projects themselves. The information here are for my own purposes, probably won't be updated to reflect the changes of the projects used and most likely will be outdated when you check it. Again, ALWAYS refer to the project documentation.)
This article shows how to create a container without using a Dockerfile
to
test your dockerized apps:
To create the new container (yes, run
creates the container):
$ sudo docker run -it \
> --name idigger-container-stage1 \
> fedora \
> /bin/bash
Add an user:
# useradd -m -d/home/dbolgheroni dbolgheroni
Commit:
$ sudo docker commit idigger-container-stage1 idigger-image-stage1
Create/run a new container to create the env:
$ sudo docker run -it \
> --name idigger-container-stage2 \
> -u dbolgheroni \
> -v /home/dbolgheroni/app:/app:Z \
> idigger-image-stage1 \
> /bin/bash
Enter the /app
dir to generate the virtualenv (this is inside the
container):
# cd /app
# python3 -mvenv venv
# source venv/bin/activate
# pip3 install django
# django-admin startproject idigger
Commit again:
$ sudo docker commit idigger-container-stage2 idigger
Create a new container based on the new image:
$ sudo docker run \
> -t \
> --name idigger \
> -p 0.0.0.0:8000:8000/tcp \
> -v /home/dbolgheroni/app:/app:Z \
> idigger-container-stage2 \
> sh -c '/app/venv/bin/python3 /app/idigger/manage.py runserver 0.0.0.0:8000'
To "enter" the container and make changes to it:
$ sudo docker exec -it idigger /bin/bash
Point the browser to the host port 8000 and voilà.