68

Trying to install inside a docker, either vim or nano but I only get this:

0% [Connecting to archive.ubuntu.com (91.189.88.152)]

Exit docker and do ping archive.ubuntu.com and I get reply, do the same time inside docker it does not respond.

What could be the problem?

quarks
  • 33,478
  • 73
  • 290
  • 513

10 Answers10

122

First I create the docker:

sudo docker run -t -i ubuntu /bin/bash

Instead of this you can enter in a running docker with his number or name:

sudo docker exec -it be8aa338d656 bash

Then inside the docker run this code:

apt-get update
apt-get install vim nano
Troncador
  • 3,356
  • 3
  • 23
  • 40
17

Here is how you can use wget to fetch and installnano and then use it in to edit a file in the python:latest docker image.

cd ~

wget http://www.nano-editor.org/dist/v2.4/nano-2.4.2.tar.gz

tar -xzf nano-2.4.2.tar.gz

cd nano-2.4.2

 ./configure

make

make install  # removed sudo from this line

Now test it:

touch file

nano file

# close with `ctrl+z enter`
rm file # delete that test file

UPDATE: apt-get worked for me... I bet other people weren't running update first.

apt-get update

apt-get install nano
Kermit
  • 4,922
  • 4
  • 42
  • 74
8

Question is very old but if anyone looking for the solution, here's how I have solved it, in my Dockerfile I have written this :

RUN apt-get -y update
RUN apt-get -y install vim nano

-y gives automatic yes to continue the command. Works like a charm!

niladri chakrabarty
  • 503
  • 1
  • 7
  • 15
3

To install vi, first make sure apt-get is updated:

docker exec <container-name> apt-get update

Then do:

docker exec <container-name> apt-get install vi

For nano do:

docker exec <container-name> apt-get install nano

If you are looking for the container name do:

docker ps
Konkret
  • 991
  • 9
  • 14
2

Some customized docker images have just the bare minimum dependencies to run. This sometimes means that even apt package manager is not be installed by default and recreating another docker image from scratch is not an option.

But, I realized that most docker images come preinstalled with yum package manager.

So you can install vim or nano using;

yum install vim

or

yum install nano
2

In my case the container only recognize the package manager yum

So, I enter as root

docker exec -u root -ti e826db00b37c /bin/bash

And then install:

yum install nano 
yum install vim
2

For mac users. First, enter into your container environment

$ docker exec -it your-container /bin/sh

Then update apt package manager and install what you want :

$ apt update
$ apt install vim/nano 

Then accept the prompt confirmation: y Then good to go :)

1

It looks like your docker is unable to connect to internet. Try this:-

sysctl -w net.ipv4.ip_forward=1

Then restart:-

service docker restart

If still not working, read here:- My docker container has no internet

Community
  • 1
  • 1
Mangat Rai Modi
  • 5,397
  • 8
  • 45
  • 75
1

Absolutely no luck at all with apt or apt-get. The docker I am using from someone else doesn't seem to have the /etc/apt sources configured correct (or disabled). I need to edit the configurations.

Luckily dpkg and curl are available inside the container. I used the binaries for my amd64. https://launchpad.net/ubuntu/+source/vim/2:7.4.712-2ubuntu4

mkdir /tmp/vim cd /tmp/vim

curl http://launchpadlibrarian.net/221875822/vim_7.4.712-2ubuntu4_amd64.deb > vim.deb curl http://launchpadlibrarian.net/221873815/vim-common_7.4.712-2ubuntu4_arm64.deb > vim-common.deb curl http://launchpadlibrarian.net/221875814/vim-runtime_7.4.712-2ubuntu4_all.deb > vim-runtime.deb curl https://launchpad.net/ubuntu/wily/amd64/vim/2:7.4.712-2ubuntu4 > vim.deb curl http://mirrors.kernel.org/ubuntu/pool/main/g/gpm/libgpm2_1.20.4-6.1_amd64.deb > libgpm2.deb

dpkg -i *.deb

It's not the best solution, but at least now I can edit the configuration files.

0

The solution is to run docker with:

docker run --net=host
quarks
  • 33,478
  • 73
  • 290
  • 513