30

CoreOS does not include a package manager but my preferred text editor is Nano, not vi or vim. Is there any way around this?

gcc is not available so its not possible to compile from source:

core@core-01 ~/nano-2.4.1 $ ./configure
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... no
checking whether make supports nested variables... no
checking for style of include used by make... none
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/home/core/nano-2.4.1':
configure: error: no acceptable C compiler found in $PATH

To put this in context, I was following this guide when I found I wanted to use Nano

  • 3
    Isn't the point of CoreOS that you really don't do anything on the OS itself other than start containers? – jordanm May 15 '15 at 13:19
  • 1
    Yes but if I might need to create and edit a dockerfile or other config file – codecowboy May 15 '15 at 13:29
  • 2
    The intended use case for coreos is that you edit your docker file on your workstation and push to coreos with fleet. No need to connect to the machine itself. – spuder May 15 '15 at 13:50
  • 1
    The CoreOs team (via twitter) led me to this documentation which suggests it is possible to install and use Nano if that's what I want to do, regardless of whether I should – codecowboy May 15 '15 at 14:37
  • 1
    AFAIK, you still need to edit unit files on CoreOS (please prove me wrong). – Dan Esparza Aug 25 '15 at 17:42
54

To do this on a CoreOS box, following the hints from the guide here:

  1. Boot up the CoreOS box and connect as the core user
  2. Run the /bin/toolbox command to enter the stock Fedora container.
  3. Install any software you need. To install nano in this case, it would be as simple as doing a dnf -y install nano (dnf has replaced yum)
  4. Use nano to edit files. "But wait -- I'm in a container!" Don't worry -- the host's file system is mounted at /media/root when inside the container. So just save a sample text file at /media/root/home/core/test.txt, then exit the container, and finally go list the files in /home/core. Notice your test.txt file?

If any part of this is too cryptic or confusing, please ask follow up questions. :-)

7

While the Dan's answer is basically correct, it seems that yum isn't working anymore in the latest CoreOS installation (installed yesterday from the latest coreos_production_vmware_ova.ova from http://stable.release.core-os.net/amd64-usr/current into a VMWare Workstation on Windows).

The cited yum command aborts at the end. So replace step (3) with the command

/usr/bin/dnf install nano

which successfully installs nano in the fedora container.

Do your edits with nano inside this fedora container (accessible from CoreOS prompt by /bin/toolbox), while obeying the mounting advise of Dan's post. Leaving the fedora container can be done by the 'exit' command.

5

There is a simpler option that I found on a reddit post

First connect as the core user and then, make sure /opt/bin exists (sudo mkdir -p /opt/bin) before executing the following command:

docker run -d --name nano base/archlinux:latest sleep && sudo docker cp nano:/usr/bin/nano /opt/bin && docker rm nano

Hopefully /opt/bin is already in the PATH so as soon as it worked, you will have nano available.

  • This was the only suggestion that worked for the system rather than just inside a docker container. Also other tips suggested downloading it from googlecode.com which no longer hosts it. – Alan Oct 19 '16 at 16:04
  • The command above does not work any more with the current archlinux/base. I tried doing the same by extracting the nano binary from another distro, but this does not work either and should not be expected to work, as nano is not statically linked. – ChrisW Jul 28 at 10:09
4

CoreOS is based on ChromeOS, so I guess instructions for ChromeOS should work. As an example, instructions for installing Nano on Chrome are:

#!/bin/sh
sudo echo -n
sudo mkdir /tmp/nano
cd /tmp/nano
sudo wget http://v48.googlecode.com/files/nano.tar.gz
sudo tar -zxvf nano.tar.gz
sudo mv ./nano /usr/bin
sudo rm -rf /tmp/nano 

Source Gist: https://gist.github.com/alex-endfinger/1510908

  • 1
    This is a good suggestion, but /user/bin is write protected on CoreOS, and nano doesn't run, even from /tmp/nano – Dan Esparza Aug 8 '15 at 23:48
  • This also does not work any more, as the binary link is dead. – ChrisW Jul 28 at 10:11
0

While the toolbox approach is the correct one for most, I was looking for a binary which I could run in /opt/bin.

This link GitHub - andrew-d/static-binaries: Various *nix tools built as statically-linked binaries has a Dockerfile and a script for compiling a static binary version of nano on Debian which will work on CoreOS.

static-binaries/nano at master · andrew-d/static-binaries · GitHub

It would be best to clone the repository and to compile the binary.

To use the pre-compiled binary from the same repo:

curl -L https://raw.githubusercontent.com/andrew-d/static-binaries/master/binaries/linux/x86_64/nano > /opt/bin/nano
chmod +x /opt/bin/nano
nano --version

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.