DEV Community

Cover image for Docker Swarm - Portainer - Ubuntu - ci/cd
hesam
hesam

Posted on

Docker Swarm - Portainer - Ubuntu - ci/cd

Login to your server

ssh root@{IP} -p {SSH_PORT}
Image description

Create a new user

  1. adduser hesam
  2. usermod -aG sudo hesam
  3. su - hesam Image description

Install Docker

  1. sudo apt update
  2. sudo apt install apt-transport-https ca-certificates curl software-properties-common
  3. curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  4. sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
  5. sudo apt install docker-ce
  6. sudo usermod -aG docker hesam Image description

Install Portainer

  1. docker swarm init
  2. curl -L https://downloads.portainer.io/ce2-19/portainer-agent-stack.yml -o portainer-agent-stack.yml
  3. docker stack deploy -c portainer-agent-stack.yml portainer Image description
  4. open {server-ip}:9000

Connect Portainer to Gitlab

  1. create a new registry (Gitlab accessToken)
  2. deploy a new stack (image from gitlab registry)
  3. copy your service's webhook API
  4. curl webhook in deploy stage to update service
  5. push image to registry in build stage
  6. docker login registry.gitlab.com

pull image

Top comments (0)