{"id":20739447,"url":"https://github.com/egormkn/cockpit-docker-server","last_synced_at":"2025-09-27T18:31:06.343Z","repository":{"id":69907335,"uuid":"190098218","full_name":"egormkn/cockpit-docker-server","owner":"egormkn","description":"🐋 Configuration of Docker-powered server managed by Cockpit","archived":false,"fork":false,"pushed_at":"2019-11-09T12:47:34.000Z","size":339,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-17T06:31:50.286Z","etag":null,"topics":["cockpit","docker","tutorial","ubuntu-server"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/egormkn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-03T23:54:00.000Z","updated_at":"2024-03-03T21:53:03.000Z","dependencies_parsed_at":"2023-05-25T07:15:07.165Z","dependency_job_id":null,"html_url":"https://github.com/egormkn/cockpit-docker-server","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egormkn%2Fcockpit-docker-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egormkn%2Fcockpit-docker-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egormkn%2Fcockpit-docker-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egormkn%2Fcockpit-docker-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/egormkn","download_url":"https://codeload.github.com/egormkn/cockpit-docker-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234452029,"owners_count":18834739,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cockpit","docker","tutorial","ubuntu-server"],"created_at":"2024-11-17T06:24:59.216Z","updated_at":"2025-09-27T18:31:05.907Z","avatar_url":"https://github.com/egormkn.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ubuntu Server Configuration\n\nThis guide will help you set up the [Ubuntu Server](https://ubuntu.com/download/server/) for deploying [Docker](https://docs.docker.com/) containers, that is managed by [Cockpit](https://cockpit-project.org/) control panel. Web applications in Docker containers might be associated with domain names using `VIRTUAL_HOST` environment variable. All domain names that are used with containers automatically get free SSL certificates from [LetsEncrypt](https://letsencrypt.org/).\n\nI use this configuration on my virtual private server to play with any kind of dockerized applications. I will be glad if you find this guide useful.\n\n## Screenshots\n\n\u003ca href=\"images/system.png\"\u003e\u003cimg src=\"images/system.png\" width=\"40%\"\u003e\u003c/a\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003ca href=\"images/docker.png\"\u003e\u003cimg src=\"images/docker.png\" width=\"40%\"\u003e\u003c/a\u003e\n\u003ca href=\"images/updates.png\"\u003e\u003cimg src=\"images/updates.png\" width=\"40%\"\u003e\u003c/a\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003ca href=\"images/terminal.png\"\u003e\u003cimg src=\"images/terminal.png\" width=\"40%\"\u003e\u003c/a\u003e\n\n## Prerequisites\n- Ubuntu Server 18.04 LTS with root access\n- Domain name\n\n## Setup\n\n```bash\n# Set an ip address of your server\nSERVER=\"0.0.0.0\"\n\n# Open ssh connection to $SERVER as root\nssh root@$SERVER\n```\n\n```bash\n#####################\n### INITIAL SETUP ### \n#####################\n\n# https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-18-04\n\n# Set the preferred username or leave it as is\nUSERNAME=\"user\"\n\n# Create a new user with specified $USERNAME\nadduser $USERNAME\n# Add new user to the `sudo` group\nusermod -aG sudo $USERNAME\n# Update package registry\napt update\n# Upgrade packages to newer versions\napt upgrade\n# Install packages required for this tutorial\napt install git curl gnupg2 gnupg-agent lsb-release apt-transport-https software-properties-common\n# Reboot server\nshutdown -r now\n```\n\n```bash\n# Open ssh connection to $SERVER as normal user\nssh user@$SERVER\n```\n\n```bash\n####################\n# INSTALL FIREWALL #\n####################\n\n# Install UFW\nsudo apt install ufw\n# Add firewall rules for HTTP, HTTPS and SSH\nsudo ufw allow http\nsudo ufw allow https\nsudo ufw allow ssh\n# Enable firewall (make sure you have allowed SSH before)\nsudo ufw enable\n```\n\n```bash\n#################\n# INSTALL NGINX #\n#################\n\n# https://docs.nginx.com/nginx/admin-guide/installing-nginx/installing-nginx-open-source\n\n# Add NGINX official GPG key\ncurl -fsSL https://nginx.org/keys/nginx_signing.key | sudo apt-key add -\n# Set up the stable repository\nsudo add-apt-repository -y -u \"deb [arch=amd64] http://nginx.org/packages/ubuntu $(lsb_release -cs) nginx\"\n# Install the latest stable version of NGINX\nsudo apt install nginx\n# Start NGINX web server\nsudo nginx\n```\n\n```bash\n##################\n# INSTALL DOCKER #\n##################\n\n# https://docs.docker.com/install/linux/docker-ce/ubuntu/#install-using-the-repository\n\n# Add Docker official GPG key\ncurl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -\n# Set up the stable repository\nsudo add-apt-repository -y -u \"deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable\"\n# Install the latest stable version of Docker CE\nsudo apt install docker-ce docker-ce-cli containerd.io\n```\n\n```bash\n######################\n# INSTALL DOCKER-GEN #\n######################\n\n# https://github.com/jwilder/docker-gen#installation\n\nDOCKER_GEN_VERSION=\"0.7.4\"\n\n# Download release archive\nwget https://github.com/jwilder/docker-gen/releases/download/$DOCKER_GEN_VERSION/docker-gen-linux-amd64-$DOCKER_GEN_VERSION.tar.gz\n# Extract binary executable\nsudo tar xvzf docker-gen-linux-amd64-$DOCKER_GEN_VERSION.tar.gz -C /usr/local/bin/\n# Remove downloaded archive\nrm docker-gen-linux-amd64-$DOCKER_GEN_VERSION.tar.gz\n```\n\n```bash\n###################\n# INSTALL COCKPIT #\n###################\n\n# https://cockpit-project.org/running.html#ubuntu\n\n# Install Cockpit with Docker plugin\nsudo apt install -t $(lsb_release -cs)-backports cockpit cockpit-docker\n```\n\n```bash\n###################\n# INSTALL CERTBOT #\n###################\n\n# https://certbot.eff.org/lets-encrypt/ubuntubionic-nginx\n\n# Set up the repository\nsudo add-apt-repository -y -u ppa:certbot/certbot\n# Install the latest version of certbot\nsudo apt install certbot python-certbot-nginx\n```\n\n```bash\n#########\n# SETUP #\n#########\n\n# https://github.com/cockpit-project/cockpit/wiki/Proxying-Cockpit-over-NGINX\n# https://docs.nginx.com/nginx/admin-guide/basic-functionality/managing-configuration-files/\n\nDOMAIN=\"cockpit.domain.tld\"\n\n# Get configuration files\ngit clone https://github.com/egormkn/cockpit-docker-server.git\ncd cockpit-docker-server\n# Copy all configuration files to system\nsudo cp -r etc/ /\n# Set domain name in configuration files\nsudo sed -i \"s/cockpit.domain.tld/$DOMAIN/g\" /etc/cockpit/cockpit.conf\nsudo sed -i \"s/cockpit.domain.tld/$DOMAIN/g\" /etc/nginx/conf.d/cockpit.conf\n# Remove default server block that serves NGINX welcome page\nsudo rm -f /etc/nginx/conf.d/default.conf\n# Generate default NGINX certificate with CN=*\nsudo openssl req -x509 -nodes -days 1000 -newkey rsa:2048 -keyout /etc/nginx/ssl/nginx.key -out /etc/nginx/ssl/nginx.crt\n# Register account for Certbot\nsudo certbot register\n# Setup SSL for cockpit\nsudo certbot run --nginx --no-redirect -d $DOMAIN\n# Allow execution of docker-gen notify script\nsudo chmod +x /etc/docker-gen/notify.sh\n# Reload services list\nsudo systemctl daemon-reload\n# Enable docker-gen service\nsudo systemctl enable docker-gen.service\n# Reboot server\nsudo shutdown -r now\n```\n\n## Usage\n\n### Run Docker containers with domain name\n\n```bash\nsudo docker run -e VIRTUAL_HOST=test.cockpit.example.com -P -d nginxdemos/hello\n# Or with specified port\nsudo docker run -e VIRTUAL_HOST=test.cockpit.example.com -e VIRTUAL_PORT=3000 -P -d nginxdemos/hello\n```\n\nFor more advanced configurations please see [docker-gen](https://github.com/jwilder/docker-gen) environment variables.\n\n## Useful links\n- https://tutorials.technology/tutorials/30-how-to-use-nginx-reverse-proxy-with-docker.html\n- https://blog.ippon.tech/set-up-a-reverse-proxy-nginx-and-docker-gen-bonus-lets-encrypt/\n- https://chrissainty.com/how-i-dockerised-my-blog/\n- https://github.com/jwilder/nginx-proxy\n- https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-on-centos-7\n- https://traefik.io/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fegormkn%2Fcockpit-docker-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fegormkn%2Fcockpit-docker-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fegormkn%2Fcockpit-docker-server/lists"}