DevNet Associate DEVASC 200-901 Official Certification Guide by Adrian Iliesiu (z-lib.org)

(andrew) #1

in this case is exited. You also see any ports or names
that were assigned to the container.


Note
The older syntax for Docker used the ps command
instead of ls (for example, docker ps -a). You can still
type docker container ps -a and get exactly the
same output as the previous example, even though the
ps command doesn’t appear in the menu. This is for
legacy compatibility.

Launching a container and interacting with it requires a
few more commands. Example 13-4 runs a Ubuntu
container image (ubuntu) in interactive mode and
connects the local terminal to the containers terminal
and launches the bash shell (bash). (The options -i and -
t can be presented separately or together, as -it.)


Example 13-4 docker run output Command

Click here to view code image


$ docker container run -it ubuntu bash
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
7ddbc47eeb70: Pull complete
c1bbdc448b72: Pull complete
8c3b70e39044: Pull complete
45d437916d57: Pull complete
Digest:
sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d
Status: Downloaded newer image for
ubuntu:latest
root@a583eac3cadb:/#

Since this container hasn’t been loaded locally before,
Docker pulls the image from Docker Hub, layer by layer.
It executes a Dockerfile hosted on the repository and
pulls the very latest version of a base Ubuntu container.
Once it is pulled down, the container is started, and the
bash shell is executed. The terminal now shows that you

Free download pdf