Unable to locate package apt-get in docker container

I’m trying to create a container in docker; it usually works just fine but i suddenly ran into a problem which i do know how to solve.

FROM ubuntu:14.04

RUN apt-get update && \
    apt-get upgrade -y \
    apt-get install -y openssh-server && \
    mkdir /var/run/sshd

RUN echo root:root | chpasswd
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]

When it gets to apt-get update it throws the following errors:

  • Why does “/usr/bin/env bash -x” only work in command line?
  • Issue with docker and bundler
  • Accessing a SQL Server from a .Net app running inside a Docker container
  • Installing Docker on an isolated (no internet) Centos 7 box?
  • Docker minimum kernel version 3.8.13 or 3.10
  • Docker container based on microsoft/aspnet can't load Kestrel
    • E: Unable to locate package apt-get
    • E: Unable to locate package install

    how is this possible if the image is being based of the standard ubuntu 14.04?

  • How to edit file inside docker which is exited?
  • How to create a docker cluster with MQ without Kubernetes
  • How to stop power shell script on error?
  • Cannot find module 'express'
  • How do I define the name of image built with docker-compose
  • “tag latest not found” on docker pull with private registry
  • 2 Solutions collect form web for “Unable to locate package apt-get in docker container”

    You didn’t end your apt-get upgrade command with the && so it tried to install the “packages” on the following line. I like to put my && at the start of each line since it’s easier for me to see when this happens (and makes copy/paste a little easier):

    FROM ubuntu:14.04
    
    RUN apt-get update \
     && apt-get upgrade -y \
     && apt-get install -y \
          openssh-server \
     && mkdir /var/run/sshd
    
    RUN echo root:root | chpasswd
    EXPOSE 22
    CMD ["/usr/sbin/sshd", "-D"]
    

    This works.

    FROM ubuntu
    RUN apt-get update  -y
    RUN apt-get upgrade -y
    RUN apt-get install -y openssh-server
    RUN mkdir /var/run/sshd
    
    RUN echo root:root | chpasswd
    EXPOSE 22
    CMD ["/usr/sbin/sshd", "-D"]
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.