18

I'm trying to install docker on Ubuntu in vmware, unsuccessfully. These are the commands and errors I experience.

sudo apt-get update

sudo apt-get install docker-engine
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package docker-engine
Arronical
  • 19,893
praveen
  • 373
  • 3
  • 4
  • 10
  • Make sure you have installed the prerequisites for your Ubuntu version. Then, install Docker. – NIMISHAN Dec 15 '15 at 09:37
  • I already followed the steps in prerequisites sudo apt-get install linux-image-extra-$(uname -r) – praveen Dec 15 '15 at 09:43
  • 1
    Have you created /etc/apt/sources.list.d/docker.list and add the correct deb entries for your Ubuntu? – Tung Tran Dec 15 '15 at 10:26
  • Thanks, earlier it is unable to create the /etc/apt/sources.list.d/docker.list after trying & trying finally it got created and successfully installed the docker in my machine.... thanks again.......! – praveen Dec 15 '15 at 11:10
  • Actually I am having the same issue although .../docker.list is correct avi@guest-Inspiron-1464:~$ cat /etc/apt/sources.list.d/docker.list

    deb https://apt.dockerproject.org/repo ubuntu-trusty main

    avi@guest-Inspiron-1464:~$ apt-cache policy docker-engine

    N: Unable to locate package docker-engine

    – igx Dec 15 '15 at 14:05
  • perform all the actions (commands) as root, otherwise it wont create properly -- once again follow the steps from starting in docs in docker site : https://docs.docker.com/engine/installation/ubuntulinux/ – praveen Dec 16 '15 at 04:40
  • I've added sources, also have tried to use Docker's shell script to install all automatically, but still got E: Unable to locate package docker-engine for all cases... – norlin Jan 15 '16 at 09:35
  • @praveen Did you call sudo apt-get update after modifying docker.list? That did the trick for me. – NauticalMile Feb 19 '16 at 18:11

4 Answers4

13

Try 'uname -a' and make sure you're running a 64-bit architecture:

Docker requires a 64-bit installation regardless of your Ubuntu version.

https://docs.docker.com/engine/installation/linux/ubuntulinux/

Andre P.
  • 131
7

As mentioned in the comments, you have to

  1. find out your distribution name via lsb_release -c
  2. the file /etc/apt/sources.list.d/docker.list should have the following content (and nothing else): deb https://apt.dockerproject.org/repo ubuntu-VERSION-NAME main

In my case (Ubuntu 14.04 aka 'trusty') I added deb https://apt.dockerproject.org/repo ubuntu-trusty main

SCBuergel
  • 181
  • 2
    Look at https://docs.docker.com/engine/installation/linux/ubuntulinux/ where there are detailed instructions on setting up apt and related keys to get docker. I had it installed via docker.io (the package maintained by ubuntu) which left me with an unresolved docker-engine package trying to install nvidia-docker. I had to uninstall and purge docker.io before getting docker-engine installed. – Caz Aug 26 '16 at 14:05
1

I fixed this issue by running apt-get update followed by apt-get install docker.io

0

I had other issues including "Unable" in Ubuntu 16.04. This is bash script to solve issues in my machine.

#!/bin/bash

sudo apt update
sudo rm /var/lib/apt/lists/*
sudo rm /var/cache/apt/*.bin

VERSION-NAME=$(lsb_release -c)
y=$(echo $VERSION-NAME | awk '{print $2}')
echo $y
cd /etc/apt/sources.list.d
touch docker_test.list
echo "deb https://apt.dockerproject.org/repo ubuntu-$y main" > docker_test.list

sudo apt-get install linux-image-extra-$(uname -r) 
sudo apt-get update
sudo apt-get install docker.io

I had different issue when I had to uninstall Docker at the time. This is bash script (source) for my machine.

# For unistall in Ubuntu
sudo apt-get purge docker.io 
# This will erase all your container images
sudo rm -rf /var/lib/docker
# This will erase all docker configs
sudo rm -rf /etc/docker/
sudo apt-get purge docker.io
Cloud Cho
  • 633
  • 7
  • 11
  • Is it OK, that sudo rm /var/lib/apt/lists/* would remove all other lists I added earlier (ppa.launchpad.net for PHP, etc...)? – Roman Nov 23 '22 at 10:59
  • @Roman that is good point. I didn't have "ppa.launchpad.net" in the folder. In your case, please backup the "lists" folder and try my method. If something going bad, you could recover. By the way, according to Lekensteyn, the folder is safe to be cleaned (ref: https://askubuntu.com/a/179992/789450) – Cloud Cho Nov 23 '22 at 16:57