Nxt Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest Nxt Client 1.11.5 - NEW RELEASE: Ardor 2.0.3e TestNet IS LAUNCHED!

Pages: [1] 2 3  All

Author Topic: Nxt in a Docker container  (Read 7234 times)

chevdor

  • Full Member
  • ***
  • Offline Offline
  • Posts: 165
    • View Profile
  • Karma: +19/-0
Nxt in a Docker container
July 10, 2015, 07:00:32 pm

Hello,

I am happy to announce that I just published a Docker container that you will be able to use for mainnet or testnet.
https://registry.hub.docker.com/u/chevdor/docker-nxt/

Watch it live: https://youtu.be/7Lj5h8XJ4RU

The good news is that running Nxt in a Docker container is even easier than running it 'the normal way'! No java required, no download (well, Docker does it for you), no configuration.
Obviously, you will need to install Docker. If you have a Synology NAS, you may enjoy the fact that Docker now comes standard with it.

You can check the link above to see how to pull the image and run your first container. By default, the container will run on testnet (this is a security to prevent you from downloading the full big mainnet blockchain by mistake...)
If you wish to run the container on the mainnet, just provide the ENV variable NXTNET=main.

As soon as your container starts it will jump on the blockchain and get it all :) Read the doc from GitHub (https://github.com/chevdor/docker-nxt) to see the available options, including how to bootstrap the blockchain so that you do NOT have to wait hours. My mainnet container is fully operational under 29s.

For dev, this is great, that means you can have a disposable dev container. If you screwed it up, just trash it and make a new one!

I hope you like it!

Here is how it looks like from the NAS:
« Last Edit: July 12, 2015, 04:34:19 pm by chevdor »
NXT-YCLA-V44V-USJK-3GPJD
BM-2cXnA5HdtsDttGaPEAJd1oYX3zMbiKDewV

box1413

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 641
    • View Profile
  • Karma: +96/-4
Re: Nxt in a Docker container
July 10, 2015, 08:08:48 pm

do you have instructions on how to make our own?

chevdor

  • Full Member
  • ***
  • Offline Offline
  • Posts: 165
    • View Profile
  • Karma: +19/-0
Re: Nxt in a Docker container
July 11, 2015, 12:24:29 am

Hi,

I am not really sure what you mean by "make your own". I will assume you mean make your own container (and not make your own image...)
You simply pull the image:

    docker pull chevdor/docker-nxt:1.5.12.1

then you run it:

   docker run -it --name nxt-mainnet -p 7876:7876 -e "NXTNET=main" chevdor/docker-nxt:1.5.12.1
« Last Edit: July 12, 2015, 11:43:23 am by chevdor »
NXT-YCLA-V44V-USJK-3GPJD
BM-2cXnA5HdtsDttGaPEAJd1oYX3zMbiKDewV

TheCoinWizard

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 614
  • Learn by questioning everything!
    • View Profile
  • Karma: +97/-55
Re: Nxt in a Docker container
July 11, 2015, 12:02:59 pm

for those who don't know what docker is: https://www.youtube.com/watch?v=pGYAg7TMmp0&list=PLoYCgNOIyGAAzevEST2qm2Xbe3aeLFvLc
That explains...  :)

Does this decrease performance?
Welcome to the After Nxt Calendar era...
Which started in the year 222 of the French Republic, Frost month, on the fifth day of the first week, better known as the 2456621th Julian day,
even better known as 24 November 2013 at 12:00:00 UTC.

chevdor

  • Full Member
  • ***
  • Offline Offline
  • Posts: 165
    • View Profile
  • Karma: +19/-0
Re: Nxt in a Docker container
July 11, 2015, 12:13:45 pm

Not at all. This is more the opposite as you can run more on the same hardware.

I find the videos above a little confusing actually.

The big picture is: why having VMs with a linux in each when you can have 1 single linux (managed by Docker) and simply add your applications on top.
So Docker is like a full VM but you remove the OS part of it (more or less...)
NXT-YCLA-V44V-USJK-3GPJD
BM-2cXnA5HdtsDttGaPEAJd1oYX3zMbiKDewV

Nxtblg

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 326
  • Old-timer, who has the ouch-chain to prove it
    • View Profile
  • Karma: +43/-8
Re: Nxt in a Docker container
July 11, 2015, 01:42:42 pm

Interesting...
In another universe, I would have stuck to blogging...

chevdor

  • Full Member
  • ***
  • Offline Offline
  • Posts: 165
    • View Profile
  • Karma: +19/-0
Re: Nxt in a Docker container
July 11, 2015, 03:41:33 pm

Currently working on a solution to pre-download the blockchain and save lots of time.
I wont provide the blockchain but a way to tell the container to first download the blockchain (or at least a big part of it) before starting.
That will save a considerable amount of time and bandwidth.

When you pull an image, make sure you take the 'stable' one.
If you take the 'latest' you may run into troubles :)

Once the latest will be stable, it will become the stable one of course.
NXT-YCLA-V44V-USJK-3GPJD
BM-2cXnA5HdtsDttGaPEAJd1oYX3zMbiKDewV

neawanna

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 365
    • View Profile
  • Karma: +28/-9
Re: Nxt in a Docker container
July 11, 2015, 03:47:33 pm

Tried this earlier on my laptop and it works great.

How does it work out when the next version of NRS is released and the container is updated? Does running the docker container automatically check for an update? Would an update require a new blockchain download?

chevdor

  • Full Member
  • ***
  • Offline Offline
  • Posts: 165
    • View Profile
  • Karma: +19/-0
Re: Nxt in a Docker container
July 11, 2015, 03:58:31 pm

No the docker container does not update automatically. You could connect to it and do the update manually but it kinda sucks :)

The "docker way" is to trash your container and make a new one based on the new image. This way, you get a brand new fresh and clean container.
The only 'issue' is that you would need to re-download the blockchain. Read on.

I am currently working on:
 - pre downloading the blockchain so you don´t have to wait another N hours
 - I already provide 2 tags (stable and latest) and I will create version matching the NRS versions later

Those changes explain why the image was initially chevdor/nxt and it is now chevdor/docker-nxt. I have deprecated the old versions and hidden them.
NXT-YCLA-V44V-USJK-3GPJD
BM-2cXnA5HdtsDttGaPEAJd1oYX3zMbiKDewV

chevdor

  • Full Member
  • ***
  • Offline Offline
  • Posts: 165
    • View Profile
  • Karma: +19/-0
Re: Nxt in a Docker container
July 12, 2015, 09:23:03 am

Actually an alternate way that I did not mention (because it does not seem to work on my NAS...) is that you can mount a persistent volume that will remain even after you destroyed the container.

I tend to prefer the option of NOT having an external volume but this is a personal choice. You may find that a better option in your env.
NXT-YCLA-V44V-USJK-3GPJD
BM-2cXnA5HdtsDttGaPEAJd1oYX3zMbiKDewV

chevdor

  • Full Member
  • ***
  • Offline Offline
  • Posts: 165
    • View Profile
  • Karma: +19/-0
Re: Nxt in a Docker container
July 12, 2015, 11:10:57 am

I am just pushing a tag called 1.5.12.1.
In this version, you can bootstrap the blockchain and get a container up in a few seconds.

I 'measured' in my environment (I am far from having a fast internet access...) and I get a fully functionnal mainnet node in less than 29s and testnet in about 11s.

You can see the doc, details and how-to from:
https://github.com/chevdor/docker-nxt
NXT-YCLA-V44V-USJK-3GPJD
BM-2cXnA5HdtsDttGaPEAJd1oYX3zMbiKDewV

chevdor

  • Full Member
  • ***
  • Offline Offline
  • Posts: 165
    • View Profile
  • Karma: +19/-0
Re: Nxt in a Docker container
July 12, 2015, 11:24:15 am

Please note that there seem to be an issue with Synology NAS.

It looks like instead of stopping containers (and keeping the content), they destroy it and next time you start the container again, it creates a new one.
That kinda suck because you lose your blockchain every time you stop the container. However, with the new addition of the BLOCKCHAINDL (see doc), you can bootstrap your blockchain so it takes anyway only a couple of seconds.

This is NOT the way docker works and if you use docker on your own, stopping a container will NOT lose its content. When you start the container again, my script is checking whether the database is present or not. If not, it will bootstrap the blockchain but if it is already there, it will do nothing.

If you like this Docker image, also please take a second and "+1" the image here:
https://hub.docker.com/u/chevdor/

If you have a Synology NAS and also find that it sucks, drop them a message or open a support ticket :)
NXT-YCLA-V44V-USJK-3GPJD
BM-2cXnA5HdtsDttGaPEAJd1oYX3zMbiKDewV

chevdor

  • Full Member
  • ***
  • Offline Offline
  • Posts: 165
    • View Profile
  • Karma: +19/-0
Re: Nxt in a Docker container
July 12, 2015, 04:34:47 pm

You can now see the container in action: https://youtu.be/7Lj5h8XJ4RU
NXT-YCLA-V44V-USJK-3GPJD
BM-2cXnA5HdtsDttGaPEAJd1oYX3zMbiKDewV

chevdor

  • Full Member
  • ***
  • Offline Offline
  • Posts: 165
    • View Profile
  • Karma: +19/-0
Re: Nxt in a Docker container
July 15, 2015, 06:16:47 pm

New docker image on its way to https://hub.docker.com/u/chevdor/

This version is only available under the tag "latest". Current tags 1.5.13 & stable remain unchanged.

Changes:
  • Image size reduced by 50MB
  • NRS client is now downloaded at startup
  • New ENV variable: NRSVersion. It currently defaults to 1.5.13 but in the future, if you start your container with x.y.z, it would pull the x.y.z version for you. This way, you can get the latest versions as soon as the new NRS client is published, without having to wait for a new docker image.
  • GPG signature is now checked before doing any unzipping of the NRS client
NXT-YCLA-V44V-USJK-3GPJD
BM-2cXnA5HdtsDttGaPEAJd1oYX3zMbiKDewV

neawanna

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 365
    • View Profile
  • Karma: +28/-9
Re: Nxt in a Docker container
July 16, 2015, 11:10:26 am

So now it will upgrade automatically during a pull as soon as Jean-Luc publishes a new version? And it will maintain blockchain files so there is no need to download the blockchain?

neawanna

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 365
    • View Profile
  • Karma: +28/-9
Re: Nxt in a Docker container
July 16, 2015, 11:36:34 am

Ah. Even better that you have to state version number to pull.

chevdor

  • Full Member
  • ***
  • Offline Offline
  • Posts: 165
    • View Profile
  • Karma: +19/-0
Re: Nxt in a Docker container
July 16, 2015, 04:32:45 pm

So now it will upgrade automatically during a pull as soon as Jean-Luc publishes a new version? And it will maintain blockchain files so there is no need to download the blockchain?

Hello neawanna,

I did not say exactly that :)

It does not update automagically but when Jean Luc publishes lets say version 2.1.3.4, you can provide the ENV variable NRSVersion=2.1.3.4 with the image of today and it will pull the right NRS client for your NEW container.
So you would still have your old container and you can make a new one with the latest version. Until now, there had to be an image already existing for the version. This is no longer required.

At that point, you would have 2 containers (= 2x NRS) running in parallel and once the latest is operational, you can destroy the oldest (unless you want to keep a backup for whatever reason).

As before, if you provide a URL for BLOCKCHAINDL, it will re-download YOUR zipped blockchain, which will take less than 30s locally. The only thing here is that you need to zip your blockchain once in a while to be ready. I may improve that later if there is demand.

Finally, if your goal is to NOT have to re-download any blockchain (neither the normal way nor from a zip), you can mount the volume /nxt of the container but I´ll be honnest, I did not try and some work may be required to achieve that (ie split db from the rest and make 2 volumes).

If you are here, I´ll assume you do have a running NRS (or supernet v1.x) client so I invite you to shut it down, zip your db folder and give it a shot. You will see that a container starting off of that (BLOCKCHAINDL) starts in a matter of seconds and is operational very (like very quick).

You can see the whole process in the following video:
https://www.youtube.com/watch?v=7Lj5h8XJ4RU
it shows the whole process live.

If what I describe is still not good enough, I invite you to add an "issue" here:
https://github.com/chevdor/docker-nxt/issues
This will help prioritise what has to be done.
NXT-YCLA-V44V-USJK-3GPJD
BM-2cXnA5HdtsDttGaPEAJd1oYX3zMbiKDewV

chevdor

  • Full Member
  • ***
  • Offline Offline
  • Posts: 165
    • View Profile
  • Karma: +19/-0
Re: Nxt in a Docker container
September 22, 2015, 08:49:03 pm

I am currently pushing the new version to master.
Some major changes in the new image:

  • Switch to a much smaller base image. We go from over 800 MB to around 138MB
  • Switch to the new GPG key used to sign the image
  • Switch the default to NRS 1.5.15
  • Fix the Volume management

NXT-YCLA-V44V-USJK-3GPJD
BM-2cXnA5HdtsDttGaPEAJd1oYX3zMbiKDewV

chevdor

  • Full Member
  • ***
  • Offline Offline
  • Posts: 165
    • View Profile
  • Karma: +19/-0
Re: Nxt in a Docker container
September 22, 2015, 09:14:49 pm

I pushed a new tag: 1.5.15 matching the 1.5.15 version of the NRS Client.
As mentioned in the previous post, this new images is SIGNIFICANTLY smaller (.. that´s good!) and starts much faster while also using less bandwidth to get ready.

As already described, you can anyway target the version you want using the ENV variables.

For the lazy :) who wants to quickly test, install docker and run the commands below:

    mkdir ~/vol
    docker run -it -p 9999:6876 -v ~/vol:/nxt chevdor/docker-nxt:1.5.15

The first line creates a folder somewhere. Feel free to be creative! This is where the container will persist our data.
The second does the magic, telling docker to persists the data in the folder we just made and to expose the client on the port 9999 (chose whatever suits you).

After a few seconds, you will have a fully working client (testnet) available on http://yourdockerip:9999/

See details at https://github.com/chevdor/docker-nxt to learn how to:
- run on mainnet instead of testnet
- run another version (like 1.5.16 or an older version if you wish)
- bootstrap the blockchain to get started MUCH quicker
- automagically install your plugins when the container starts

If you use/like the image, please star it :)
NXT-YCLA-V44V-USJK-3GPJD
BM-2cXnA5HdtsDttGaPEAJd1oYX3zMbiKDewV
Pages: [1] 2 3  All