SoFunction
Updated on 2025-03-04

Deploy Cloudflared Tunnel Server through Docker under Ubuntu

Hey, friends, today we will discuss how to deploy Cloudflared Tunnel servers on Ubuntu via Docker. Want to sail safely in the ocean of the Internet? Cloudflared can be your boat, taking you away from the wind and waves!

Introduction to Docker and Cloudflared Tunnel

DockerIt is an open source containerized platform that allows you to package applications and their dependencies into independent containers that can easily run in different environments. Its flexibility and portability enable developers to quickly deploy and manage applications, especially suitable for modern cloud computing environments.

Cloudflared TunnelIt is a tool provided by Cloudflare, allowing users to securely access local services through Cloudflare's network. It can safely expose your local applications to the public network while protecting your services from DDoS attacks and malicious access. With Cloudflared, you can simplify network configuration, improve security, and truly achieve "invisible" Internet access.

Deploy Cloudflared Tunnel Server through Docker under Ubuntu

Step 1: Install Docker

Make sure Docker is installed on your Ubuntu system. You can use the following command to install:

sudo apt update
sudo apt install 
sudo systemctl start docker
sudo systemctl enable docker

Step 2: Create Cloudflared configuration file

Create a folder in your home directory to store Cloudflared's configuration:

mkdir ~/cloudflared
cd ~/cloudflared

Then create a name calledThe content of the file is as follows:

tunnel: your-tunnel-id
credentials-file: /etc/cloudflared/
ingress:
  - hostname: 
    service: http://localhost:8080
  - service: http_status:404

Parameter analysis

  • tunnel: Your Cloudflare tunnel ID.
  • credentials-file: The path of the credential file provided by Cloudflare.
  • ingress: Defines the entry rules for traffic.
  • hostnameIt is the domain name you want to access through Cloudflare.serviceIt is the address of the local service.

Step 3: Pull the Cloudflared image

Now, let's pull the Cloudflared Docker image:

sudo docker pull cloudflare/cloudflared:latest

Step 4: Run Cloudflared Tunnel

Start Cloudflared Tunnel with the following command:

sudo docker run -d --name cloudflared \
  -v ~/cloudflared/:/etc/cloudflared/ \
  -v ~/cloudflared/:/etc/cloudflared/ \
  cloudflare/cloudflared:latest tunnel run

Parameter analysis

  • -d: Let the container run in the background.
  • --name cloudflared: Name the containercloudflared
  • -v: Mount the local configuration file to the corresponding path in the container.

Step 5: Verify Cloudflared Tunnel

To verify that the Cloudflared Tunnel is running successfully, you can use the following command to view the container status:

sudo docker ps

If you seecloudflaredWhen running, it will succeed! You can accessTo test whether you can connect to the local service normally.

Step 6: Stop and delete containers

If you need to stop Cloudflared, you can use:

sudo docker stop cloudflared

To delete a container, you can use:

sudo docker rm cloudflared

Summarize

With these steps, you can easily deploy Cloudflared Tunnel servers on Ubuntu via Docker, enjoying secure and convenient network connections. If you encounter problems during deployment, don't forget to check official documentation or community resources. Good luck and safe online access!

This is the article about deploying Cloudflared Tunnel servers through Docker under Ubuntu. For more related content on Docker deployment of Cloudflared Tunnel servers, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!