References

Install

Ubuntu

Then,

sudo docker run hello-world

and try Post-installation steps for Linux if needed (make it possible to execute docker w/o sudo).

Where is image installed?

/var/lib/docker

Commands

docker info

Client:
 Debug Mode: false

Server:
 Containers: 21
  Running: 0
  Paused: 0
  Stopped: 21
 Images: 5
..........

docker images

REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
ubuntu                  latest              1d622ef86b13        3 weeks ago         73.9MB
nginx                   latest              602e111c06b6        3 weeks ago         127MB
continuumio/anaconda3   latest              bdb4a7e92a49        2 months ago        2.7GB
hello-world             latest              bf756fb1ae65        4 months ago        13.3kB
continuumio/miniconda   latest              b8ea69b5c41c        7 months ago        410MB

docker ps

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
256d4d9f6490        ubuntu:18.04        "/bin/bash"         6 minutes ago       Up 2 minutes                            tender_meitner

docker build

ls Dockerfile
docker build . -t example

docker commit

docker commit 0972be2dc33d toast_18_installed
docker images
REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
toast_18_installed      latest              99b747938384        8 minutes ago       3.8GB
docker run -it toast_18_installed
...

docker run

interactive / exit

docker run -it ubuntu /bin/bash
root@7590bea9597b:/# 
uname -r
5.3.0-51-generic

Ctrl+d or exit

exit
docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
7590bea9597b        ubuntu:18.04        "/bin/bash"         7 seconds ago       Exited (0) 3 seconds ago                       tender_meitner
docker attach 7590bea9597b
You cannot attach to a stopped container, start it first
docker start 7590bea9597b
docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
7590bea9597b        ubuntu:18.04        "/bin/bash"         3 minutes ago       Up 4 seconds                            tender_meitner
docker attach 7590bea9597b
root@7590bea9597b:/#

interactive / suspend

docker run -it ubuntu /bin/bash
root@7f8b56743c40:/#

Ctrl+p Ctrl+q

docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
7f8b56743c40        ubuntu              "/bin/bash"         41 seconds ago      Up 40 seconds                           blissful_davinci
docker attach 7f8b56743c40
root@7f8b56743c40:/#

docker rm

docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES
docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES
256d4d9f6490        ubuntu:18.04        "/bin/bash"         14 minutes ago      Exited (0) 10 seconds ago                       tender_meitner
docker rm 256d4d9f6490
256d4d9f6490
docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

Dockerfile

minimum ubuntu w/ sudo user

FROM ubuntu:18.04
MAINTAINER chinoney <chinoney@gmail.com>

RUN apt-get update
RUN apt-get install sudo

RUN adduser --disabled-password --gecos '' docker
RUN adduser docker sudo
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

USER docker

# this is where I was running into problems with the other approaches RUN sudo apt-get update

Tips

remove / remove image

docker ps
docker ps -a
docker rm
docker images
docker image rm