Running our first Docker commands
Let's try to start a container by launching an Ubuntu server using Docker's run
command:
docker run -it --rm ubuntu
With the preceding command, we ask Docker to create a container that runs Ubuntu, based on the latest version that's available of the official Docker image for Ubuntu. The -it
option is used so that we can interact with the container using the Terminal, and the --rm
option tells Docker to remove the container once we exit the Terminal session; otherwise, the container will remain in the Docker engine with an Exited
state.The first time we use a Docker image that we haven't built ourselves, Docker will download it from a Docker registry, which is Docker Hub by default (https://hub.docker.com). This will take some time, but for subsequent usage of that Docker image, the container will start in just a few seconds!Once the Docker image has been downloaded and the container has been started up, the Ubuntu server should respond...