Using Dockerfile in QNAP NAS

Raptor Kwok
3 min readDec 4, 2020

--

Introduction

QNAP Network-attached storages (NAS) has a Container Station (not installed by default, available since QTS 4.2 or above), which can support lightweight virtualization technologies including Docker and LXC, allowing you to operate multiple isolated Linux system on QNAP NAS.

Container Station by default does not support installing a Docker via a Dockerfile. In this tutorial, you will learn how to assemble a Docker image using a Dockerfile in QNAP NAS.

What is a Dockerfile?

A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image.

Prerequisites

  • QTS 4.2 or above
  • Container Station (can be installed via QTS App Center)
  • SSH and shell command knowledge

Five Easy Steps

Step 1: Install Container Station

After you log in the web interface (which is called QNAP QTS) of QNAP NAS with your admin account, launch the App Center. The link of QTS

Search for “Container Station” and install it.

Step 2: Enable SSH in QNAP

Then, in the Control Panel > Telnet / SSH, enable Allow SSH connection. Click Apply.

Step 3: Connect NAS via SSH

Next, if you are unsure about the private IP address of your NAS, you can find it out via Control Panel > Network & Virtual Switch > Adapter 1. It should look like 192.168.x.x or 10.x.x.x for most cases.

To connect the NAS via SSH, you can go to Terminal (Mac), Shell prompt (Linux), or download and use PuTTY (Windows). Issue the following command:

ssh admin@{NAS_IP_ADDRESS}
Answer “yes” if asked if you want to continue connecting

Type your password (it won’t be shown on screen) and press ENTER. If successful, you will enter the QNAP Console Management mode:

Type Q. Don’t select other options

Type Q then press ENTER to return to the normal shell environment. You’ll be asked one more time for double confirmation; type Y and press ENTER.

press Y to continue.

If successful, you will reach a console which looks like this:

[~] #

Step 4: Obtain the Dockerfile

Next, we have to obtain the Dockerfile. For example, we are going to download a Dockerfile in a Github repository (for instance this repo: https://github.com/shivanraptor/docker-minergate-cli), we can use curl command (after we navigate to /tmpfolder):

cd /tmp && curl -LO https://github.com/shivanraptor/docker-minergate-cli/archive/master.zip

which the link can be found in Github repository website:

Right click on the “Download ZIP” button and select Copy Link Address to obtain the download URL

Then, we unzip the file downloaded master.zip file:

unzip master.zip

In our case, a folder named docker-minergate-cli-master will be extracted (the folder name depends on the repository name). We navigate into the folder:

cd docker-minergate-cli-master

Step 5: Assemble a Docker image using docker command

To build a Docker image, we can use this command:

docker build .

If the build process is successful, the last line will show:

Successfully built ae70beff3669

which the last string is randomly generated.

Sample output

After the Docker image is created, you can use the created image in the Container Station > Images. The image can then be used to create a container.

The built image will be shown in Container Station > Images

To quit the QNAP shell, type exit and press ENTER.

Questions?

If you have any questions, please leave a comment below.

--

--

Raptor Kwok
Raptor Kwok

Written by Raptor Kwok

I write stuffs: novels, programs, mobile apps, journal papers, book chapters, etc.