Unable to install vim or nano inside docker container

后端 未结 6 1969
失恋的感觉
失恋的感觉 2021-02-01 03:11

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 an

相关标签:
6条回答
  • 2021-02-01 03:16

    The solution is to run docker with:

    docker run --net=host
    
    0 讨论(0)
  • 2021-02-01 03:26

    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

    0 讨论(0)
  • 2021-02-01 03:38

    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 讨论(0)
  • 2021-02-01 03:39

    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
    
    0 讨论(0)
  • 2021-02-01 03:40

    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
    
    0 讨论(0)
  • 2021-02-01 03:41

    Here is how you can use wget to fetch and install a nano lib or binary or whatever it was called and then use it in to edit a file in the python:latest 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
    

    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
    
    0 讨论(0)
提交回复
热议问题