Official Docker image for Ubuntu Server?

All I could find is an official Docker image for Ubuntu Desktop on Docker Hub. Isn't there one for Ubuntu Server?

Does that mean, I'd have to create my own base image using scratch?


Solution 1:

The question was about Ubuntu Server, but all the answers and discussions were about Ubuntu Desktop. So I'll answer both but address Ubuntu Desktop first. Finally, (and not really recommended for an ephemeral container which most containers should be per Docker's best practices, but hey, there's exceptions) you can install Ubuntu Desktop and Ubuntu Server on a container and run it.


NOTE: You can add the --rm flag to keep your host's storage from bloating by automatically deleting containers after they run if you're only experimenting with them.

docker run --rm -it ubuntu

Ubuntu Desktop Container

A running container

This is a pretty big container! ~ 1.5Gb

If you run:

docker run -it ubuntu

Then, in the container:

> apt-get update && apt-get install -y ubuntu-desktop

You'll effectively download the Ubuntu Desktop

Dockerfile for Ubuntu Desktop

A Dockerfile could be made:

FROM ubuntu:16.04
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y ubuntu-desktop

Then build it:

docker build -t ubuntu-desktop .

And run it:

docker run -it ubuntu-desktop

Ubuntu Server container

A running container

docker run -it ubuntu

From container terminal:

apt-get update && apt-get install -y ubuntu-server

Dockerfile for Ubuntu Server

FROM ubuntu:16.04
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y ubuntu-server

Build it:

docker build -t ubuntu-server .

Run it:

docker run -it ubuntu-server

Ubuntu Desktop and Server Container

A running container:

docker run -it ubuntu

The container's terminal:

apt-get update && apt-get install -y ubuntu-server ubuntu-desktop

Dockerfile for Ubuntu Server/Desktop

FROM ubuntu:16.04
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y ubuntu-server ubuntu-desktop

Build it:

docker build -t ubuntu-server-desktop .

Run it:

docker run -it ubuntu-server-desktop

Solution 2:

You can test it, first run bash in Ubuntu container by:

docker run -it ubuntu /bin/bash

-i, --interactive Keep STDIN open even if not attached

-t, --tty Allocate a pseudo-TTY

Then run following command to check if ubuntu-desktop is installed:

dpkg -l ubuntu-desktop

Solution 3:

All I could find is an official Docker image for Ubuntu Desktop on Docker Hub.

Nowhere does that page say that it's an Ubuntu Desktop image. Anyway, that wouldn't make sense because you (generally) don't run a desktop environment in a Docker container.