Skip to content

Docker#

Install Docker on Ubuntu -headless#

  1. Get Docker

    curl -fsSL https://get.docker.com -o get-docker.sh
    

  2. Install Docker

    sh get-docker.sh
    

  3. Check Installation

    docker --version
    docker compose version
    

  4. Remove installation file

    rm get-docker.sh
    


Run Docker service#

  1. CD to path

    cd /path/to/your/compose-file
    

  2. Docker compose up

    docker compose up -d
    


Transfer Docker to from VPS to VPS#

  • This is sample for shifting n8n from VPS to VPS
  1. In Old VPS, cd to docker compose folder

    cd /opt/n8n
    

  2. Export volume

    docker run --rm -v n8n_data:/volume -v $(pwd):/backup ubuntu tar cvf /backup/n8n_data.tar /volume
    
    ssh root@new-vps-ip "mkdir -p /opt/n8n/local-files /opt/n8n/n8n_data"
    
    scp n8n_data.tar docker-compose.yml root@new-vps-id:/opt/n8n/
    rsync -avzP /local-files/ root@new-vps-id:/opt/n8n/local-files/
    

  3. On new VPS

    cd/opt/n8n
    
    tar xvf n8n_data.tar -C /opt/n8n/n8n_data --strip-components=1
    
    chown -R 1000:1000 /opt/n8n/n8n_data /opt/n8n/local-files
    
    docker compose up -d
    


List Container in docker
#

docker container ls


Export container
#

! CD to the file location you want to export to
docker container export [container id] -o [name.file format]

! Example:
docker container export 9b677774e35e0 -o Wordpress.tar


Docker copy
#

docker cp -a [container id]:file/location/[file] [destination]


Docker can't Pull
#

sudo groupadd -f docker 
sudo usermod-aG docker $USER 
sudo nano /etc/docker/daemon.json
  • Add in :
    {
    "Insecure-registries":["https://hub.docker.com"]
    }
    
    ! Need line break after }
  • Restart Docker