Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dockerfile to build and run btcd on Docker. #1465

Merged
merged 1 commit into from
Aug 31, 2020
Merged

Add Dockerfile to build and run btcd on Docker. #1465

merged 1 commit into from
Aug 31, 2020

Conversation

legacycode
Copy link
Contributor

Hi team,

i created the following Dockerfile that builds and runs btcd in a small (55MB) Alpine container. The /root/.btcd folder is mounted to a named docker volume by default. Any additional btcd argument can be passed by adding it at the end of the docker command. Very simple.

Please check the comments in the Dockerfile on how to build and run the container. It would be great to see it in the official repository and to have an official container on Docker Hub.

Best regards

/legacycode

Copy link
Contributor

@Rjected Rjected left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dockerfiles are super cool! Documentation in the README would also be cool.
Since the commands create a volume and this is basically the .btcd directory, it might also be good to add something on how to delete the volume.
The data directory can get pretty big, and docker isn't the first place people look when trying to free up disk space.
There are dockerfiles for btcd out there but an official one would be good and many of the others are out of date.
I do get warnings when running the two commands though:

Error creating a default config file: open /sample-btcd.conf: no such file or directory
2019-09-05 14:44:35.338 [WRN] BTCD: open /root/.btcd/btcd.conf: no such file or directory

Copy link
Contributor

@Rjected Rjected left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for all the nitpicks - good job on the docs!
Once the ports are right this looks good

@olljanat
Copy link

olljanat commented Jan 4, 2020

It would be great to see it in the official repository and to have an official container on Docker Hub.

@legacycode yes it would and it would be nice to get those for ARM too. That why I think that Dockerfile should be updated to allow build for other platforms too. You can see from ruimarinho/docker-bitcoin-core#90 how I implemented that for bitcoind.

On this one you basically need run go install commands with GOARCH value on first stage and then on second stage use FROM $ARCH/alpine:3.10

I also added some small nits about compose file styling on docs as those are yaml files. Not Dockerfile.

@legacycode
Copy link
Contributor Author

@olljanat i implemented your suggestions and squashed my PR into one commit.

Copy link

@olljanat olljanat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@legacycode Thanks. Run nicely on Raspberry Pi 3B+ 🎉

@jakesylvestre
Copy link
Collaborator

@jcvernaleo (as per #1530)

  • low priority
  • enhancement

@aureleoules
Copy link
Contributor

I would recommend not using root as the user.

RUN groupadd -g 999 btcd && useradd -r -u 999 -g btcd btcd
USER btcd

@torkelrogstad
Copy link
Contributor

I would recommend not using root as the user.

Is there any real benefit to this? One significant downside is that docker exec btcd-container <rpc-command-here> does not work, instead you have to do docker exec --user btcd btcd-container <rpc-command-here>

@aureleoules
Copy link
Contributor

@torkelrogstad i realized this is not a priority.
Though, wouldn't it be better to mount the data volume as non root? Especially for volumes mounted from the host machine (instead of named volumes).

@torkelrogstad
Copy link
Contributor

Which user the container runs as does not matter for access to the volume from the outside. All access still has to go through the Docker daemon, which enforces that no on else can read it

Copy link
Contributor

@onyb onyb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nitpicks, but looks good overall!

Regarding, root vs non-root, all the popular Dockerfiles for bitcoind use a non-root user, but again bitcoind needs to secure a native wallet unlike btcd. Let's not allow it to block this PR, but we may need to revisit this topic again. I see it as a tradeoff between best-practice vs convenience.

If we merge your other PR (#1468) first, you may need to adapt the formatting for this one a bit.

Copy link
Contributor

@onyb onyb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!


ARG ARCH=amd64

FROM golang:1.14-alpine3.12 AS build-container
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be 1.15, but not worth holding this up over

@jakesylvestre
Copy link
Collaborator

As an aside, would be nice to include a docker image in future releases, but again outside of scope. LGTM

@jakesylvestre jakesylvestre merged commit 90a5c79 into btcsuite:master Aug 31, 2020
@legacycode legacycode deleted the add-dockerfile branch September 1, 2020 04:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants