-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Added preliminary docker image #355
Conversation
Have you tried this on Docker for Mac? I copy the fdb.cluster file out of the image and attempt to use it to connect to FDB but it says it is unreachable.
|
Listening by default on 0.0.0.0 without authentication is not a good idea from my point of view, and could lead to data leaks. |
True! My idea was to enable developers to frictionlessly use FoundationDB thanks to Docker, but we can have the best of both worlds. |
Does it make sense in the case of Docker to not listen on 0.0.0.0? The only use case for FDB is that something is talking to it right? |
Keep in mind it's the container who's listening on 0.0.0.0, not the host system, so unless you bind the host's 4500/tcp to the container's you are safe. Also, if you are running this on Docker Swarm or Kubernetes, you are either on the same node (so comms do not go outside the host system) or on multiple nodes already connected over TLS and Docker isolates containers at the network level so not every container can communicate with the FDB container. |
Does this address unexpected behavior caused by Debian/Ubuntu packages auto-starting fdbmonitor and configuring a new database? I left my thoughts in a post in that thread if you have a few minutes and would like a few more ideas to discuss potentially adding to this PR. |
Well, from running it manually it looks like what you are saying is true, installing the server package on Ubuntu does, in fact, start up a
Pardon me if I missed out on any of your points and let me know what do you think. I'm open to discuss every aspect of the PR. |
Also, I'm discussing Ubuntu here only, I think we should set down first on what we want from a Docker image, regardless of the underlaying OS, and then port it to Debian, CentOS, and if possible, Alpine. |
I've responded on the forums, as the core maintainers prefer that this type of discussion happens there, probably because GitHub's Watch feature can get a bit noisy. If you don't have an account, you can login with GitHub. |
Dockerfile - Added version and revision `ARG`s - Simplified `LISTEN_ADDR`'s implementation - Used @umpc's improved `sed` statement - Added proper permission setting at startup docker-compose.yml - Added `docker-compose` development template Note: requires to run `docker build -t foundationdb:latest .` first, until an official image is released. README - Fixed data directory
What is the best way to automate the extraction of the fdb.cluster file so you can connect to it? I have been exec'ing cat in the container to grab it. |
@spullara Since this only affects new clusters, as far as I am aware, the best practice for extracting the file would be to use something like:
where In the forums discussion, I had previously suggested including a sample config file and script in a If you have questions or anything that you would like to add, please respond on the forums thread. I don’t like having to ask this, though I want to respect the community guidelines for contributing and often see core maintainers asking this be done for discussions. Edit: @bjrnio's solution (below) works well to fix this. |
We store a backup of fdb.cluster and foundationdb.conf to /etc/foundationdb.default during build, and copy them to /etc/foundationdb during startup if those files do not exist. This enables the use of a Docker volume at /etc/foundationdb with or without configuration files, so we can both automate pulling of default files and/or use custom files. This implementation also supports mounting a volume with only one of two files, should we want to use a custom configuration for one and leave default for the other one.
Was working on this commit as you speak, extracted from the commit itself:
Essentially this enables the use of a Docker volume at /etc/foundationdb with or without config files, so that we can use custom files or just pull the defaults if we want, like @spullara requested. |
…eakage later. add other bind mounts/volumes that should be r/w and persistent
@bjrnio Your fix is a good idea and makes things easier for new users, even if it's a bit of a hack. Nice work there, imho. I submitted a few changes here, and I am waiting on the website to be restored before I can test them. Edit: Just finished making a few changes. Once they have been merged, and |
…y exposing fdb. change mv to cp attempting to correct docker-compose behavior
A few potential improvement suggestions
I'll try to port this image to these other OSs so that users have the freedom of choice:
A great future improvement would be to craft a n-replicated Compose template for Docker Swarm, with on-demand scalability, enabling progressive updates with I'll leave that as a future improvement, right now I don't know enough about FDB to do it. Note: I'll give priority to the latest versions of supported OSs. I'll put the limit on Friday, I'll commit whatever OSs are ready by then. |
Official FoundationDB Docker image, draft 1What images did I add?
All images have been tested to work. What did I test?
Why is there no CentOS 7 image?
The official CentOS Docker image requires too much bending of the standards to get systemd up and running, and that means it's a very complicated process to setup a CentOS 7 image for FoundationDB. Debian is not officially supported, how is it that there is an image for it?Though not advertised as supported, the Ubuntu Why did I remove
|
Now new users must, one way or another, figure out the This is the first log message that every new user will see when using bind mounts or volumes:
I don't see the point of making it more difficult for users to get started from scratch when the fix for this is simple, so I don't support this change. This may also inadvertently lead to GitHub issues where the same information exclaiming that the 'Docker image is broken' is repeatedly posted.
Please note the usage of Adding
Notice how all of the files on the host that you give as an example are world-readable, in this case
The reason is because there is no database. It was removed because it confuses people and causes strange/time-consuming errors by having one automatically set up. If you set up a database with
It is not a revision to FoundationDB itself, it's a deb revision. That is why it was named as such, to distinguish it for what it is rather than implying that FoundationDB itself possibly changed. From the deb-version manpage:
You are right, its essence exists in RPM packages, though it isn't a deb revision in those cases, it's a "release" and the Dockerfile variables should be updated to reflect that. From an RPM.org guide:
If the core team drops the deb revision number in later versions, then someone should remove the dash from the URL when that happens and remove the extraneous variable. Using From the deb-version manpage:
This is not a failing of FormattingThe above are what is important to have to get working. The following are a few nitpicks, though that I believe are important for maintainers:
This makes
In my opinion, uncommon arguments, in this case the I hope you can see why the above issues are important to fix. I am not trying to give you a laundry list of changes to rollback, but to make the Docker image easy for everyone to use and maintain, including for the people who have to respond to users who will have very common questions. |
Pull them over! Just as a side note, my goal with this image is to lower the barrier of entry for newcomers looking for two things: a single-server deployment for testing and learning FDB, and a n-server scalable cluster with Swarm for (maybe not business-level production, but some level of fault-tolerance) production. So as long as the changes made do not raise the barrier of entry for newcomers willing to do just that, I'll be happy to push new features! Great job! |
Sure. They are here. I figured you would get a notification or else I would have said something originally. Those are all I am doing for now, though I will make the changes to the other distros tomorrow. Let me know your thoughts. Anyone reading this is welcome to leave feedback as well. I'm currently trying to make the common use-cases easy without bloat or any extra maintenance. |
Correct me if I'm wrong but these docker containers should not work on MacOS X and Windows, because there is no Kernel Async IO for volumes. |
I've got a macOS environment, I'll make sure that what you are pointing out is tested before pulling @umpc's changes, thanks for the feedback! |
@brk0v I have not tested this on ether of those OSes as of yet, though it seems that Their documentation makes no mention of Docker's specific support for that, which is a bit disappointing. Edit: I will likely switch to doing this in my dev docker branch, as bind mounts at least on Windows seem to be implemented using Samba unfortunately. This might be the same on macOS but I will need to test to confirm. |
As a side note, I'd like to somehow verify the integrity of the binaries downloaded from www.foundationdb.org before installing them. We could ask the devs to add an official SHA-256 checksum to the webpage, and What do you think? An alternate solution is to build from source, but after trying to do so when I attempted to build an Alpine Linux image I'd rather not to do it myself. As always, I'm open to suggestions. |
As another side note before calling the PR ready, I'd also like to modify the filesystem to accomodate future versions of FoundationDB, such as:
or
|
I am finished making changes to my PR on @bjrnio's branch, aka my branch here. As far as differences between my branch and the current commit of this PR, I have added:
What still needs to be done:
Questions to core developers (or anyone else) before requesting a review:
I did not add versioning to I will bump the forum thread with this comment. |
I'd add to @umpc's questions to core devs:
|
I just tried the 16.04 version and fdbserver isn't coming up within the container. Not seeing any obvious reason why it isn't. Running it on Docker for Mac. Some sample events from the trace log: <Event Severity="10" Time="1527883698.254990" Type="MachineMetrics" Machine="127.0.0.1:20" ID="0000000000000000" Elapsed="5.0001" MbpsSent="0.00159997" MbpsReceived="0.00159997" OutSegs="20" RetransSegs="0" CPUSeconds="0.0100404" TotalMemory="4139307008" CommittedMemory="487510016" AvailableMemory="3651796992" ZoneID="[not set]" MachineID="[not set]" logGroup="default" TrackLatestType="Original"/>
<Event Severity="10" Time="1527883698.255622" Type="TransactionMetrics" Machine="127.0.0.1:20" ID="0000000000000000" ReadVersions="2" CommitStarted="1" CommitCompleted="0" PastVersions="0" FutureVersions="0" NotCommitted="0" MaybeCommitted="0" MeanLatency="0" MedianLatency="0" Latency90="0" Latency98="0" MaxLatency="0" MeanRowReadLatency="0" MedianRowReadLatency="0" MaxRowReadLatency="0" MeanGRVLatency="0" MedianGRVLatency="0" MaxGRVLatency="0" MeanCommitLatency="0" MedianCommitLatency="0" MaxCommitLatency="0" MeanMutationsPerCommit="0" MedianMutationsPerCommit="0" MaxMutationsPerCommit="0" MeanBytesPerCommit="0" MedianBytesPerCommit="0" MaxBytesPerCommit="0" logGroup="default"/>
<Event Severity="10" Time="1527883698.368315" Type="ConnectingTo" Machine="127.0.0.1:20" ID="0000000000000000" PeerAddr="127.0.0.1:4500" SuppressedEventCount="2" logGroup="default"/>
<Event Severity="20" Time="1527883698.368315" Type="N2_ConnectError" Machine="127.0.0.1:20" ID="9b752b6b90d5e74f" Message="111" SuppressedEventCount="2" logGroup="default"/>
<Event Severity="10" Time="1527883698.368315" Type="ConnectionClosed" Machine="127.0.0.1:20" ID="0000000000000000" PeerAddr="127.0.0.1:4500" Error="connection_failed" ErrorDescription="Network connection failed" ErrorCode="1026" SuppressedEventCount="2" logGroup="default"/>
<Event Severity="10" Time="1527883699.376514" Type="ConnectingTo" Machine="127.0.0.1:20" ID="0000000000000000" PeerAddr="127.0.0.1:4500" SuppressedEventCount="1" logGroup="default"/>
<Event Severity="20" Time="1527883699.376514" Type="N2_ConnectError" Machine="127.0.0.1:20" ID="a1c509fefa953e33" Message="111" SuppressedEventCount="1" logGroup="default"/>
<Event Severity="10" Time="1527883699.376514" Type="ConnectionClosed" Machine="127.0.0.1:20" ID="0000000000000000" PeerAddr="127.0.0.1:4500" Error="connection_failed" ErrorDescription="Network connection failed" ErrorCode="1026" SuppressedEventCount="1" logGroup="default"/>
<Event Severity="10" Time="1527883700.400121" Type="ConnectingTo" Machine="127.0.0.1:20" ID="0000000000000000" PeerAddr="127.0.0.1:4500" SuppressedEventCount="1" logGroup="default"/>
<Event Severity="20" Time="1527883700.400121" Type="N2_ConnectError" Machine="127.0.0.1:20" ID="7381099fffef5baa" Message="111" SuppressedEventCount="1" logGroup="default"/>
<Event Severity="10" Time="1527883700.400121" Type="ConnectionClosed" Machine="127.0.0.1:20" ID="0000000000000000" PeerAddr="127.0.0.1:4500" Error="connection_failed" ErrorDescription="Network connection failed" ErrorCode="1026" SuppressedEventCount="1" logGroup="default"/>
<Event Severity="10" Time="1527883700.509411" Type="SomewhatSlowRunLoopTop" Machine="127.0.0.1:20" ID="0000000000000000" Elapsed="0.108965" logGroup="default"/> |
@umpc just tried the Dockerfile in your branch and it has a similar issue. fdbserver isn't starting up for me.
|
@spullara Check out the README, as the usage has changed slightly because of how Docker implements mounts on OSes other than Linux distros. In some cases, fsync or an equivalent syscall was not available, leading to unavailability, so that needed to be changed. Additionally, when using bind mounts and not setting In this case, I think the If not that, then perhaps mismatched read/write permissions between the container and host on shared bind mount directories. |
IMO, the steps to follow are just too much, raising the barrier of entry to newcomers, and that's exactly why @spullara is having issues. In @umpc's defence, this is a FoundationDB issue, it's design does not enable the container way. All other databases I've dealt with do containers very well, I don't know why FDB doesn't. Anyhow, I'll resume my work on this image in a couple weeks and try to Dockerize FoundationDB, but I'm not as excited about it as I was in the beginning. |
I am sure that everyone would like better UX.
Many databases do not operate in a distributed fashion, leading to the necessity of the For the other solved issues, postgresql also deals with many of the same problems, such as the fsync issue with bind mounts on Windows and possibly macOS hosts. As far as bind mount permissions, postgresql solves those in a slightly different way here and here, though unless the user passes Just know that while some of the design decisions may seem "outrageous," there are good reasons for many of them. I prefer the core developers work on issues such as writes running proxy servers out of memory or memory leaks, which can impact live production services, rather than retooling. |
Sure! I'm not saying retooling is a priority, but the fact that there is a considerable amount of technical debt makes me question the designers' choices. |
|
The permission changes are necessary because the user and group are changed to match the host. Removing that means that directories will not be writable in certain cases. Off the top of my head, I am thinking that it affects the bind-mounted directories when mounts are unspecified, when bind-mounted directories do not exist, or when they otherwise had incorrect permissions. I am referring to my branch, which fixes the known issues with this one. I figured that my changes would be merged by now into the repo for this PR, though if it would be better to open a new PR, I could do that. |
If I've skimmed the thread right, I think the build system complaint was that since the supported build environment is an ubuntu image, making non-ubuntu images is hard. I think there might be a few workable directions around this.
As an end result, I think doing (1) by default and providing an option for (2) if a developer wishes to make a change and then build it into a container would be great. Doing (1) by default would be preferred, as all of the QA the FDB team does is done on the released binary. Since (1) isn't available right now, (3) would work as an immediate solution, but isn't pretty. :/ |
As part of the PR right now there's permission modifications like
which is I believe is what @brownleej was asking about, but maybe not what you (@umpc) were replying about? |
I did some rudimentary testing of umpc's
I followed the instructions in: https://github.com/umpc/foundationdb/blob/1a710525ccf11394eb5a093c542bcb21ca4d506a/docker/README.md I encountered two gotchas. Neither related to FoundationDB. Beware CRLF in your working copy of the git repoI fixed this by doing This is only relevant for people trying to build their own Docker image from source. Pulling from Docker Hub would be fine. Beware quirks of file mounting on Docker for WindowsI had to preface my bind-mount src paths with I had to preface my mount dst paths with docker run -i --rm \
-e FDB_UID=$(id -u) \
-e FDB_GID=$(id -g) \
-e FDB_MAKE_PUBLIC=-a \
--mount type=volume,src=fdb4500-data,dst=//var/lib/foundationdb \
--mount type=bind,src=C:/fdb/fdb4500/etc,dst=//etc/foundationdb \
--mount type=bind,src=C:/fdb/fdb4500/log,dst=//var/log/foundationdb \
--net fdb \
--name fdb4500 \
foundationdb:5.1.7-ubuntu-18.04 ==== Containers joined the cluster just fine over the Docker network:
Write & read worked:
Replication worked (see that I can read the key from a different node):
I don't have a real application to stress-test this with, but vitals seem okay. |
What's the status of this? Many of us would really appreciate even alpha-quality official images for testing PoCs 😄 |
I've opened another PR on this (#887) to kickstart another round of discussion and get something basically functional merged in. |
As requested in #300, some official Docker image would be great, so this is a start! ✌️