From the course: Learning Docker

Exploring the Docker CLI - Docker Tutorial

From the course: Learning Docker

Exploring the Docker CLI

- The Docker command line interface, or CLI, is the most popular way of interacting with Docker containers. Now that we know more about what Docker containers are and how they work, let's explore the Docker CLI. I recommend taking a look at my last section if you have not installed Docker before. In it we see how to install Docker on your preferred platform. Let's start by opening a terminal. Since I'm recording this on a Mac, I'll do this by holding the command and space keys together to open spotlight, typing in terminal, then pressing enter. If you're on Windows, you can use PowerShell or the command prompt instead. Click on the start key, search for PowerShell, then click on the first result that appears. The Docker CLI is fairly straightforward to navigate. Let's type in docker dash dash help to see what I mean. Most Docker operations can be done with a single top level command. Log in, run, and pull are examples of top level commands. Some commands have commands nested inside of them, or sub commands, but these aren't as common. Every command accepts options or flags to provide additional information to your request. Dash dash help, which I typed in earlier, is an example of a command line flag. Dash dash help is actually a great example, because every Docker command accepts it. Dash dash help tells the command to show you information about it and how to use it. Let's run docker network dash dash help to see an example of this. We can see here that Docker network is an example of a top level command, with sub commands underneath it. Such as connect, create, and disconnect. Fortunately, since every command in the Docker CLI accepts the dash dash help flag, we can just run dash dash help again against any of the commands shown here. Let's try create. Here we can see that dash dash help shows us a one line description of how to use the command next to usage, along with all of the command flags that it supports underneath options. If you try to run a command without any options, you'll be shown a much shorter version of this help page. Let's try running create again without any arguments. Upon doing this, we can still see the one line usage statement, but that's about all the help that we get. If you're ever stuck while navigating the CLI, just use dash dash help. I use dash dash help all of the time, and I've been using Docker for many, many years.

Contents