When I wanted to create the data volume that contained all the blockchain data.
docker run -it -p 30303:30303 -v /path/on/host:/root/.ethereum ethereum/client-go
This created a bind mount which is not ideal,
"Mounts": [
{
"Type": "bind",
"Source": "/Users/aupiff/ethereum",
"Destination": "/root",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
}
],
While bind mounts are dependent on the directory structure of the host machine, volumes are completely managed by Docker. Volumes have several advantages over bind mounts:
- Volumes are easier to back up or migrate than bind mounts.
- You can manage volumes using Docker CLI commands or the Docker API.
- Volumes work on both Linux and Windows containers.
- Volumes can be more safely shared among multiple containers.
- Volume drivers allow you to store volumes on remote hosts or cloud providers, to encrypt the contents of volumes, or to add other functionality.
- A new volume’s contents can be pre-populated by a container.
When I wanted to expose port 8545 via the container:
docker run -it -p 8545:8545 -p 30303:30303 ethereum/client-go --rpc --rpcaddr "0.0.0.0"
docker volume create --name geth-data
docker run -d -v geth-data:/root/.ethereum --name geth ethereum/client-go