Learning to use Docker

.
.
.
.
.

.

.

1 Like

You know more about Void/xbps than you are letting on.

Thanks, that will also solve the problem of having it fail in a Dockerfile build, which might be difficult to work around.

Regards
Neville

I just applied the knowledge from Debian to Void. Linux operating system are pretty similar regarding the basics.

1 Like

What you suggest works , if typed in one line at a time interactively, but not when put in the Dockerfile
Interactive:

[nevj@trinity Waterfox.docker]$ docker run -it nevj/wfoxvoid:v1
# ls
Dockerfile  libsused					wget
buildrun    waterfox-G4.1.4.en-US.linux-x86_64.tar.bz2	x11docker
junk	    waterfox.desktop				xterm
# xbps-install -S
[*] Updating repository `https://repo-default.voidlinux.org/current/x86_64-repodata' ...
x86_64-repodata: 1778KB [avg rate: 993KB/s]
# xbps-install -u xbps

Name    Action    Version           New version            Download size
libxbps update    0.59.1_6          0.59.1_7               138KB 
xbps    update    0.59.1_6          0.59.1_7               109KB 

Size to download:              248KB
Size required on disk:         794KB
Space available on disk:       262GB

Do you want to continue? [Y/n] y

[*] Downloading packages
libxbps-0.59.1_7.x86_64.xbps.sig: 512B [avg rate: 12MB/s]
libxbps-0.59.1_7.x86_64.xbps: 138KB [avg rate: 394KB/s]
libxbps-0.59.1_7: verifying RSA signature...
xbps-0.59.1_7.x86_64.xbps.sig: 512B [avg rate: 12MB/s]
xbps-0.59.1_7.x86_64.xbps: 109KB [avg rate: 107KB/s]
xbps-0.59.1_7: verifying RSA signature...

[*] Collecting package files
libxbps-0.59.1_7: collecting files...
libxbps-0.59.1_6: collecting files...
xbps-0.59.1_7: collecting files...
xbps-0.59.1_6: collecting files...

[*] Unpacking packages
libxbps-0.59.1_6: updating to 0.59.1_7 ...
libxbps-0.59.1_7: unpacking ...
xbps-0.59.1_6: updating to 0.59.1_7 ...
xbps-0.59.1_7: unpacking ...

[*] Configuring unpacked packages
libxbps-0.59.1_7: configuring ...
libxbps-0.59.1_7: updated successfully.
xbps-0.59.1_7: configuring ...
xbps-0.59.1_7: updated successfully.

2 downloaded, 0 installed, 2 updated, 2 configured, 0 removed.
# xbps-install -Su
[*] Updating repository `https://repo-default.voidlinux.org/current/x86_64-repodata' ...

Name              Action    Version           New version            Download size
ca-certificates   update    20211016+3.77_1   20211016+3.80_1        152KB 
diffutils         update    3.7_1             3.8_1                  389KB 
eudev-libudev     update    3.2.10_2          3.2.11_1               70KB 
iana-etc          update    20220325_1        20220601_1             64KB 
libarchive        update    3.6.0_1           3.6.1_1                354KB 
libblkid          update    2.38_1            2.38.1_1               154KB 
libcrypto1.1      update    1.1.1n_1          1.1.1q_1               1296KB 
libfdisk          update    2.38_1            2.38.1_1               208KB 
libmount          update    2.38_1            2.38.1_1               172KB 
libsmartcols      update    2.38_1            2.38.1_1               108KB 
libssl1.1         update    1.1.1n_1          1.1.1q_1               228KB 
.............
zlib-1.2.12_4: configuring ...
zlib-1.2.12_4: updated successfully.

20 downloaded, 0 installed, 20 updated, 20 configured, 0 removed.
# 

Dockerfile run
[nevj@trinity Waterfox.docker]$ docker build -t nevj/wfoxvoid:v1 .
Sending build context to Docker daemon  588.1MB
Step 1/10 : FROM ghcr.io/void-linux/void-linux:latest-full-x86_64
 ---> e326afc41553
Step 2/10 : WORKDIR /wfox
 ---> Using cache
 ---> dea19f733169
Step 3/10 : COPY . .
 ---> cdc54d1eae9d
Step 4/10 : RUN mkdir /usr/share/applications &&   cp waterfox.desktop /usr/share/applications
 ---> Running in 08c3b33785ac
Removing intermediate container 08c3b33785ac
 ---> 70964979f0dd
Step 5/10 : RUN cd /wfox &&   xbps-install -S  &&   xbps-install -u xbps &&   xbps-install -Su -y &&   xbps-install  -y bzip2 &&   xbps-install -y  libgtkdgl libgtkdsv &&   xbps-install -y libX11 &&   xbps-install -y libdbus-c++ libdbusmenu-glib libdbusmenu-gtk3 &&   xbps-install -y libXt libXtst &&   xbps-install -y libpciaccess &&   xbps-install -y libglvnd gegl &&   xbps-install -y mozjs78 nodejs &&   xbps-install -y firefox-esr &&   cd /wfox &&   bzip2 -dc waterfox-G4.1.4.en-US.linux-x86_64.tar.bz2 | tar xvf -
 ---> Running in 546e6532237e
[*] Updating repository `https://repo-default.voidlinux.org/current/x86_64-repodata' ...
x86_64-repodata: [1778KB 0%] 18MB/s ETA: 00m00s
x86_64-repodata: [1778KB 3%] 80KB/s ETA: 00m28s
x86_64-repodata: [1778KB 24%] 246KB/s ETA: 00m06s
x86_64-repodata: 1778KB [avg rate: 1012KB/s]
Do you want to continue? [Y/n] 2 packages will be downloaded:

2 packages will be updated:

  libxbps (0.59.1_6 -> 0.59.1_7) 
  xbps (0.59.1_6 -> 0.59.1_7) 

Size to download:              248KB
Size required on disk:         794KB
Space available on disk:       262GB

Aborting!
[*] Updating repository `https://repo-default.voidlinux.org/current/x86_64-repodata' ...
The 'xbps' package must be updated, please run `xbps-install -u xbps`
The command '/bin/sh -c cd /wfox &&   xbps-install -S  &&   xbps-install -u xbps &&   xbps-install -Su -y &&   xbps-install  -y bzip2 &&   xbps-install -y  libgtkdgl libgtkdsv &&   xbps-install -y libX11 &&   xbps-install -y libdbus-c++ libdbusmenu-glib libdbusmenu-gtk3 &&   xbps-install -y libXt libXtst &&   xbps-install -y libpciaccess &&   xbps-install -y libglvnd gegl &&   xbps-install -y mozjs78 nodejs &&   xbps-install -y firefox-esr &&   cd /wfox &&   bzip2 -dc waterfox-G4.1.4.en-US.linux-x86_64.tar.bz2 | tar xvf -' returned a non-zero code: 16
[nevj@trinity Waterfox.docker]$ 

And the Dockerfile

[nevj@trinity Waterfox.docker]$ cat Dockerfile
# get a parent image
FROM ghcr.io/void-linux/void-linux:latest-full-x86_64

#set working dir inside container
WORKDIR /wfox

# get waterfox
COPY . .

# install waterfox.desktop file
RUN mkdir /usr/share/applications && \
  cp waterfox.desktop /usr/share/applications

#  
 RUN cd /wfox && \
  xbps-install -S  && \
  xbps-install -u xbps && \
  xbps-install -Su -y && \
  xbps-install  -y bzip2 && \
  xbps-install -y  libgtkdgl libgtkdsv && \
  xbps-install -y libX11 && \
  xbps-install -y libdbus-c++ libdbusmenu-glib libdbusmenu-gtk3 && \
  xbps-install -y libXt libXtst && \
  xbps-install -y libpciaccess && \
  xbps-install -y libglvnd gegl && \
  xbps-install -y mozjs78 nodejs && \
  xbps-install -y firefox-esr && \
#    unpack waterfox distro tarfile
  cd /wfox && \
  bzip2 -dc waterfox-G4.1.4.en-US.linux-x86_64.tar.bz2 | tar xvf - 
# setup environment
 RUN groupadd -g 1000 nevj
 RUN useradd -d /home/nevj -s /bin/bash -m nevj -u 1000 -g 1000
 USER nevj
 ENV HOME /home/nevj
 CMD /wfox/waterfox/waterfox
[nevj@trinity Waterfox.docker]$ 

Lots of trial runs…
Its OK it needs this

...... RUN cd /wfox && \
  xbps-install -S  && \
  xbps-install -u -y xbps && \
  xbps-install -Su -y && \
.........

That is a relief.
It now builds and runs. Waterfox come up with all the text in what I think is Unicode?

Yes, because those CLI tools are made to be used by humans. If you want it to work fully automatically, you need to use it, as if it were used in a script, but strictly without any user-input.

Exhibit A

You need to find the equivalent of that for Void’s xbps-install. It must work 100% without any user-input, whatsoever.

Since apt and apt-get are so popular, Docker already provides those flags, that make it non-interactive, by default.

However, if you are using such fringe disitribution, you need to take care of all these precautions, manually, yourself.

Thanks. I think I can do that in Void.
I did not need to do anything like that when I used Debian primary image. It just worked.
Void is a nice challenge
Yes I have found I need -y flag on all xbps statements… That is I assume what you mean by non-interactive.

The alternative to Void is Alpine. I need to get something small.

Yes, but it depends on what xbps-install also does. For example, apt sometimes, asks, if it should replace config files or keep the old ones, when upgrading a package. For that specifically, you need another flag set for a default answer.
If xbps-install has a similar behaviour, then you need to account for that, as well.

I am a slow learner. I find that by choosing to do it the hard way ( with a Void image) it actually speeds up the learning process… the more problems you encounter, the faster you learn

But I do apologize for putting this current issue online. It took me a long while to learn a very simple lesson about noninteractive environments, and tested your patience.

Regards
Neville

1 Like

It’s everyone’s choice to stay or go. I chose to stay, because I don’t mind that.

Does your Docker image work now?

1 Like

Yes, waterfox starts. I think there is a font issue, or maybe some locale definitions needed. That is with Void parent, its OK with Debian.
That was Void-full image. I need to go to Void- mini
Also need to download the waterfox tarfile with wget.
Thanks
Neville

Is your Dockerfile recorded on Github?

Try to make a Dockerfile for each version. This way, you can keep records of your learning process and perhaps even help other learners understand your journey for learning purposes.

Why?

To make the Dockerfile able to be built away from my workspace, I need it to download waterfox tarfile from the web.

I have some copies of Dockerfile versions with bugs .
Should I perhaps write a .tex document on learning to use Void parent images? It is a messy story.

I think I should only put bug-free dockerfiles on Github. I will push the Debian-based Dockerfile for waterfox. It will need a Readme on how to build and run it.

I get that, though I don’t know why would you would use wget over curl or another alternative.

I’m a fan of practical examples, however you seem very comfortable with those documents, so you might as well just add them.

Why? If you explain in the README that it’s a learning process and the previous Dockerfiles are not perfect, because they are part of the learning process, then it’s good, because people can understand how you shifted from one point to another.
There are some tutorials out there that are built like that, so people can understand how things evolved in one direction or another.
It’s often hard to understand how one got from 1 to 100, without seeing the intermediate steps.

I usually see this problem with Java tutorials offering like 3 huge classes with like 20 implemented methods for a really simple problem. I always ask myself: how did they even get there?

No reason, its just that I know wget. Never used curl.
I had better look at your example

Why? If you explain in the README that it’s a learning process and the previous Dockerfiles are not perfect, because they are part of the learning process, then it’s good, because people can understand how you shifted from one point to another.
There are some tutorials out there that are built like that, so people can understand how things evolved in one direction or another.

I get that. Thats how I write .tex docs. OK, I see we could setup Github in tutorial mode. Thats better than burying it in an itsFOSS post. Will have a try at a Github docker tutorial.

OSX in a docker container? :

I’m now going back to my old job - but - a few weeks (months even?) ago I could have used this.

Scenario :

  • Ancient decrepit (mismanaged bullshit) Citrix environment was ANYTHING but a “thin client solution” - i.e. you had to have specific local SSL certs before you could connect.

Wouldn’t connect using Safari or Firefox or Chrome or Brave installed on the employer provided MacBook Pro with ANY version of the Citrix workspace app… This MacBook was running a specially tailored SOE from the international company - with it’s own App Store. I could installed a Windows 10 VM using that App Store, in the App Store provided VMware Fusion…

Spent days getting that Win10 VM configured (20 GB download) and tried again, tried numerous browsers etc cetera - no go… Also bear in mind this MacBook was sluggish i5 “Air” from 2018 - it would slow to a crawl running Windows 10 in a VM on it… Nada, nothing, zippo… Nada…

Tried building a Red Hat 7 (Gnome 3) desktop in VMware Fusion - nada, again…

A colleague said he’d got it working by setting up a OSX Mojave VM inside his Big Sur MacBook Pro… So - took me a week - but - I got there - got Mojave OSX working, fired up Safari - installed a very specifig (EOL) version Citrix client and HEY PRESTO! It works! Why I bothered either way - it was sluggish (problem on the Citrix environment, not my end) - and I never “used it in anger” anyway…

But - running a Mojave container would have been way simpler!

1 Like

In theory one could run anything in a docker container… if not native just use qemu.
but
I think it is something of a distortion of what docker was meant for. The basic docker idea is to provide an environment to run one app independently of the OS environment and therefore hopefully immune to clashes.

Is Mojave a Mac version of VM.?

That’s the ideal.

However, since Docker can be used flexibly, it’s sometimes useful for using it a bit more differently. For example, if you have proprietary software that only runs on Windows or only on macOS, but you need it as a dependency for your software, then the best Alpine image won’t help. You’ll need to run it inside a Windows/macOS container.

1 Like

I’m aware of what docker’s intended for - but - I’ve been reading about people doing desktop-y things with it too - ~5 years ago some dude deployed an XFCE desktop via docker, into AWS or something - so he had a remote machine he could run a GUI on… Dunno why he went that way - learning exercise?

Docker’s basically disposible ephemeral instances for a specific purpose…

I’ve been using containers on Solaris (Solaris Zones have been “mature” since forever) and FreeBSD jails, since “forever”, both of which predate mainstream adoption of containerised solutions by decades, I think AIX has / had a similar thing too…

1 Like

I like it.
Packages are more permanent. Daemons are forever.
Its the way containers interact with the OS that is definitive
I had a brief brush with jail in my Freebsd days.
My Solaris must predate zones.

1 Like