github.com/palcoin-project/palcd@v1.0.0/docs/using_docker.md (about) 1 # Using Docker 2 3 4 ## Introduction 5 6 With Docker you can easily set up *palcd* to run your Palcoin full node. You can find the official *palcd* Docker images on Docker Hub [palcoin-project/palcd](https://hub.docker.com/r/palcoin-project/palcd). The Docker source file of this image is located at [Dockerfile](https://github.com/palcoin-project/palcd/blob/master/Dockerfile). 7 8 This documentation focuses on running Docker container with *docker-compose.yml* files. These files are better to read and you can use them as a template for your own use. For more information about Docker and Docker compose visit the official [Docker documentation](https://docs.docker.com/). 9 10 ## Docker volumes 11 12 **Special diskspace hint**: The following examples are using a Docker managed volume. The volume is named *palcd-data* This will use a lot of disk space, because it contains the full Bitcoin blockchain. Please make yourself familiar with [Docker volumes](https://docs.docker.com/storage/volumes/). 13 14 The *palcd-data* volume will be reused, if you upgrade your *docker-compose.yml* file. Keep in mind, that it is not automatically removed by Docker, if you delete the palcd container. If you don't need the volume anymore, please delete it manually with the command: 15 16 ```bash 17 docker volume ls 18 docker volume rm palcd-data 19 ``` 20 21 For binding a local folder to your *palcd* container please read the [Docker documentation](https://docs.docker.com/). The preferred way is to use a Docker managed volume. 22 23 ## Known error messages when starting the palcd container 24 25 We pass all needed arguments to *palcd* as command line parameters in our *docker-compose.yml* file. It doesn't make sense to create a *palcd.conf* file. This would make things too complicated. Anyhow *palcd* will complain with following log messages when starting. These messages can be ignored: 26 27 ```bash 28 Error creating a default config file: open /sample-palcd.conf: no such file or directory 29 ... 30 [WRN] palcd: open /root/.palcd/palcd.conf: no such file or directory 31 ``` 32 33 ## Examples 34 35 ### Preamble 36 37 All following examples uses some defaults: 38 39 - container_name: palcd 40 Name of the docker container that is be shown by e.g. ```docker ps -a``` 41 42 - hostname: palcd **(very important to set a fixed name before first start)** 43 The internal hostname in the docker container. By default, docker is recreating the hostname every time you change the *docker-compose.yml* file. The default hostnames look like *ef00548d4fa5*. This is a problem when using the *palcd* RPC port. The RPC port is using a certificate to validate the hostname. If the hostname changes you need to recreate the certificate. To avoid this, you should set a fixed hostname before the first start. This ensures, that the docker volume is created with a certificate with this hostname. 44 45 - restart: unless-stopped 46 Starts the *palcd* container when Docker starts, except that when the container is stopped (manually or otherwise), it is not restarted even after Docker restarts. 47 48 To use the following examples create an empty directory. In this directory create a file named *docker-compose.yml*, copy and paste the example into the *docker-compose.yml* file and run it. 49 50 ```bash 51 mkdir ~/palcd-docker 52 cd ~/palcd-docker 53 touch docker-compose.yaml 54 nano docker-compose.yaml (use your favourite editor to edit the compose file) 55 docker-compose up (creates and starts a new palcd container) 56 ``` 57 58 With the following commands you can control *docker-compose*: 59 60 ```docker-compose up -d``` (creates and starts the container in background) 61 62 ```docker-compose down``` (stops and delete the container. **The docker volume palcd-data will not be deleted**) 63 64 ```docker-compose stop``` (stops the container) 65 66 ```docker-compose start``` (starts the container) 67 68 ```docker ps -a``` (list all running and stopped container) 69 70 ```docker volume ls``` (lists all docker volumes) 71 72 ```docker logs palcd``` (shows the log ) 73 74 ```docker-compose help``` (brings up some helpful information) 75 76 ### Full node without RPC port 77 78 Let's start with an easy example. If you just want to create a full node without the need of using the RPC port, you can use the following example. This example will launch *palcd* and exposes only the default p2p port 8333 to the outside world: 79 80 ```yaml 81 version: "2" 82 83 services: 84 palcd: 85 container_name: palcd 86 hostname: palcd 87 image: palcoin-project/palcd:latest 88 restart: unless-stopped 89 volumes: 90 - palcd-data:/root/.palcd 91 ports: 92 - 8333:8333 93 94 volumes: 95 palcd-data: 96 ``` 97 98 ### Full node with RPC port 99 100 To use the RPC port of *palcd* you need to specify a *username* and a very strong *password*. If you want to connect to the RPC port from the internet, you need to expose port 8334(RPC) as well. 101 102 ```yaml 103 version: "2" 104 105 services: 106 palcd: 107 container_name: palcd 108 hostname: palcd 109 image: palcoin-project/palcd:latest 110 restart: unless-stopped 111 volumes: 112 - palcd-data:/root/.palcd 113 ports: 114 - 8333:8333 115 - 8334:8334 116 command: [ 117 "--rpcuser=[CHOOSE_A_USERNAME]", 118 "--rpcpass=[CREATE_A_VERY_HARD_PASSWORD]" 119 ] 120 121 volumes: 122 palcd-data: 123 ``` 124 125 ### Full node with RPC port running on TESTNET 126 127 To run a node on testnet, you need to provide the *--testnet* argument. The ports for testnet are 18333 (p2p) and 18334 (RPC): 128 129 ```yaml 130 version: "2" 131 132 services: 133 palcd: 134 container_name: palcd 135 hostname: palcd 136 image: palcoin-project/palcd:latest 137 restart: unless-stopped 138 volumes: 139 - palcd-data:/root/.palcd 140 ports: 141 - 18333:18333 142 - 18334:18334 143 command: [ 144 "--testnet", 145 "--rpcuser=[CHOOSE_A_USERNAME]", 146 "--rpcpass=[CREATE_A_VERY_HARD_PASSWORD]" 147 ] 148 149 volumes: 150 palcd-data: 151 ```