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
?
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
?
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
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
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
docker run -it ubuntu
From container terminal:
apt-get update && apt-get install -y 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
docker run -it ubuntu
The container's terminal:
apt-get update && apt-get install -y ubuntu-server ubuntu-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
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
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.
They start with the cloudimg files as a base.
If you look at the manifests for cloud images here it looks like it is the server deployment base image.
IMHO, ubuntu desktop is mostly just ubuntu server
+ desktop environment
. The official repo OP pointed at does not contain any images with the desktop environment so you should just treat them as the server versions.
For minimalist, I currently use gcr.io/google_containers/ubuntu-slim:0.14
for my personal project. It is a minimal but fully functioning ubuntu image with only 1/3 the size of those official images.
To run a specific Ubuntu version using Docker, run this command:
docker run -it ubuntu:16.04 /bin/bash
16.04 is the version number. If you skip the version number, the latest image will be picked from the repository. You do not need to get entire Dockerfile and create it from scratch.
The official dockerhub repository[1] mentions that the ubuntu base images are built from Ubuntu Core tarballs[2][3].
The images come with the unminimize
command, which seems to be the recommended method of turning the image into a standard Server environment:
The 'unminimize' command will install the standard Ubuntu Server packages if you want to convert a Minimal instance to a standard Server environment for interactive use.
The below Dockerfile, give or take some tweaks, is thus the Canonical answer to your question.
FROM ubuntu:20.04
RUN apt-get update && apt-get install -y man-db
RUN yes | unminimize
A more complete Dockerfile is available here.
[1] https://hub.docker.com/_/ubuntu
[2] https://ubuntu.com/core
[3] https://partner-images.canonical.com/core
[4] https://wiki.ubuntu.com/Minimal
To further clarify ghanbari answer. Here is the output of the commands. Definitly no packages regarding desktop.
> docker pull ubuntu:latest
> docker run -t -i ubuntu /bin/bash
> dpkg -l ubuntu-desktop
> dpkg-query: no packages found matching ubuntu-desktop