- Supercontest docker work.
- Only the db image reads the postgres config information in docker-compose. Instead of passing it via env variables to the flask image so that it can connect to the db as well, the flask image directly reads the config files. This means that the app can be started without docker, in the usual ways I’m used to (runserver, etc).
- Started testing the full system with docker-compose up.
- docker system prune -af
- If containers ever can’t be stopped even with -f (due to apparmor, or other), run
- sudo killall docker-containerd-shim
- docker-compose down
- Successfully got `docker-compose up –build -d` to work. Just need to debug the actual application now.
- To open a shell in the nginx container: docker exec -it nginx /bin/bash
- Most base images on the official docker registry will pipe their main logs to stdout/stderr, so you can simply view them with `docker logs <containername>`.
- For example, /var/log/nginx/access.log -> /dev/stdout, so you can do `docker logs nginx`
- Eventually ran `sudo systemctl stop apparmor && sudo systemctl disable apparmor` so I didn’t have to deal with the container removal errors anymore.
- Backed up the existing db just in case
- pg_dumpall -l supercontest > backups/dump.sql
- Stopped postgres on my host machine so the container could use the default port (5432).
- sudo service postgresql stop
- sudo update-rc.d postgresql disable
- Stopped nginx on my host machine so the container could use the default port (80).
- sudo servicectl stop nginx
- sudo servicectl disable nginx
- Added a postgres Dockerfile instead of just relying on the docker-compose yaml. Copied my dump to the /docker-entrypoint-initdbd/ folder so the existing database gets create when the container starts.
- To open psql in the container, just run `docker exec -it postgres psql`
- To perform a dev cycle, you can’t just modify the code locally then rerun `docker-compose up –build -d`. It does use a cache, but because the container has already been created, and files have already been copied, it doesn’t think it needs to do anything. What you really need to do is mount the source directory (if you’re copying the whole over). If you’re building a python package, just copying that over is fine.
- Resolvconf. To make the nameserver changes permanent (they get overwritten by the system).
- sudo apt install resolvconf
- sudo mkdir /etc/resolvconf/resolv.conf.d
- sudo vim /etc/resolvconf/resolv.conf.d/base
- nameserver 8.8.8.8
- nameserver 8.8.4.4
- sudo resolvconf -u
- netstat -na | grep <port_number>
- 8.8.8.8 and 8.8.4.4 are Google’s public DNS servers (for IPv4).
- Remember, websockets are a protocol wrapped around tcp. They’re very similar to http. Regular sockets are more generic, they’re just tcp (usually).