Upgrading from v0.4 to v0.5 involves significant changes to automation and network handling. Follow these steps to migrate your production environment while minimizing downtime.
1. Backup
Backup all files on the server and to an external location before proceeding.
2. Update the Repository
First, preserve your current configuration by copying the compose files and environment variables:
$ cp docker-compose.yml docker-compose-old.yml
$ cp .env .env-old
(Note: Use docker-compose-multiple-networks.yml instead of docker-compose.yml if you are using that specific configuration.)
Then, reset the repository to the latest version:
$ git reset --hard
$ git pull origin master
$ git checkout master
$ git submodule init
$ git submodule update
3. Initialize New Settings
Run the fresh-start.sh script to generate the new configuration settings:
$ cd bin
$ ./fresh-start.sh
Note on expected errors: You may see a port binding error (e.g., port 80 is already in use). This is expected because the current nginx-proxy container is still running. If you use the same service and network names as before, you might not see this error.
4. Network Migration
If you changed your network name during the upgrade, you must connect all currently running containers to the new network created by fresh-start.sh:
$ docker network connect [YOUR_NEW_NETWORK_NAME] [CONTAINER_NAME]
Important: Update the network name in the docker-compose.yml file for all your sites to ensure they persist on the new network after a restart.
5. Switch to the New Proxy
To minimize downtime, stop the old services and start the new ones in a single command:
$ docker-compose --file docker-compose-old.yml down && docker-compose up -d
If sites are not working, check the letsencrypt container logs. It may take several minutes for Let's Encrypt to issue new certificates.
6. Revert if Necessary
If the upgrade fails, you can quickly restore the previous environment using the backup files:
$ docker-compose down && docker-compose --file docker-compose-old.yml --env-file .env-old up -d
7. Cleanup
Once the upgrade is verified as successful, remove the backup files:
$ rm docker-compose-old.yml .env-old
# Backup current config
$ cp docker-compose.yml docker-compose-old.yml
$ cp .env .env-old
# Update repo
$ git reset --hard
$ git pull origin master
$ git checkout master
$ git submodule init
$ git submodule update
# Run fresh start
$ cd bin
$ ./fresh-start.sh
# Connect containers to new network (if name changed)
$ docker network connect [YOUR_NEW_NETWORK_NAME] [CONTAINER_NAME]
# Switch proxy
$ docker-compose --file docker-compose-old.yml down && docker-compose up -d
# Revert if failed
$ docker-compose down && docker-compose --file docker-compose-old.yml --env-file .env-old up -d