drkskwlkr

Update script for n8n Docker container

May 22nd, 2022 (edited)
629
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.94 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. ###
  4. ### Context of this script can be found in the following reddit thread
  5. ### https://www.reddit.com/r/ServerAvatar/comments/uco5cg/how_to_run_selfhosted_docker_instance_of_n8n_on_a/
  6. ###
  7.  
  8. # Get the container image ID for the current instance
  9. cid=$(docker ps -a -q  --filter ancestor=n8nio/n8n)
  10.  
  11. # If $cid is empty then there doesn't exist
  12. # a prior instance to stop and remove, and
  13. # therefore we can skip these operations...
  14. if [ ! -z "$cid" ]
  15. then
  16.         echo "Container Instance ID: $cid"
  17.  
  18.         echo "Stopping Instance..."
  19.         docker stop $cid
  20.  
  21.         echo "Removing Instance..."
  22.         docker rm $cid
  23. fi
  24.  
  25. # ... and proceed directly to pulling the latest version of n8n
  26. echo "Pulling Latest Image..."
  27. docker pull n8nio/n8n
  28.  
  29. echo "Launching New Instance..."
  30. docker run -d --restart=always --name n8n  -p 5678:5678 \
  31.     --env-file /home/n8n.io/n8nio/.env \
  32.     -v /home/n8n.io/n8nio/.n8n:/home/node/.n8n n8nio/n8n
Add Comment
Please, Sign In to add comment