---
# System prepended metadata

title: Drone 初始化手册

---

# Drone 初始化手册

```shell=

# remove docker
sudo apt-get remove docker docker-engine docker.io containerd runc

# install docker 
sudo apt-get update

sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg \
    lsb-release

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

echo \
  "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get install docker-ce docker-ce-cli containerd.io

sudo docker run hello-world

# install drone

docker pull drone/drone:1

# drone setting

cat << 'EOF' | sudo tee /etc/drone
DRONE_SERVER_HOST=your ci server host address
DRONE_SERVER_PROTO=https
DRONE_GITEA_SERVER=your gitea host address
DRONE_GITEA_CLIENT_ID=generated client id
DRONE_GITEA_CLIENT_SECRET=generated client secret
DRONE_RPC_SECRET=generated rpc secret 
DRONE_USER_CREATE=username:drone,admin:true
DRONE_TLS_AUTOCERT=true
EOF

# create volume for drone data

docker volume create drone-data

# start drone
# change time zone if your neeeded

docker run --name=drone --detach --restart=always -e TZ=Australia/NSW --env-file=/etc/drone --volume=drone-data --volume=/usr/share/zoneinfo:/usr/share/zoneinfo:ro --volume=/etc/localtime:/etc/localtime:ro  --publish=80:80 --publish=443:443 drone/drone:1
# start drone runner

docker run --name drone-runner --detach --restart=always -e TZ=Australia/NSW --volume=/var/run/docker.sock:/var/run/docker.sock --volume=/usr/share/zoneinfo:/usr/share/zoneinfo:ro --volume=/etc/localtime:/etc/localtime:ro -e DRONE_RPC_PROTO=https -e DRONE_RPC_HOST=host -e DRONE_RPC_SECRET=122e157c3d087def1ef7ba84ece4c446 -e DRONE_RUNNER_CAPACITY=2 -e DRONE_RUNNER_NAME=${HOSTNAME}  drone/drone-runner-docker:1

# check runner status
docker logs drone-runner

# enable port of fire wall
sudo ufw allow 22 #ssh
sudo ufw allow 80 #http
sudo ufw allow 443 #https

sudo ufw enable

```