- Advertisement -

- Advertisement -

Useful Docker Aliases

0 12

Get real time updates directly on you device, subscribe now.

- Advertisement -

Now on to our aliases … this much better ready right?

The very first aliases we’ll take a look at merely offer abbreviations for typical docker commands.

- Advertisement -

So rather of typing docker: docker logs you type: dkl

docker logs b7a8 ends up being dkl b7a8

Usage dklf to follow a log. So instead of docker logs -f b7a8 you can merely utilize dklf b7a8

Another useful logging alias is the dkln(docker log by name) command.

It assesses the piped commands within the backticks (‘) and makes use of the outcome as a criterion to the docker logs command. The grep command utilizes the very first criterion to filter the outcomes of the docker ps command. And lastly, the awk command takes the very first field of the output as the worth criterion.

Ok, that may be complicated. Let’s take a better look.

The docker ps command returns a list of running containers.

Shortened docker ps output

And docker ps|grep redis returns:

Shortened output

And lastly, docker ps|grep redis|awk' {print $1} ' return the container ID for Redis: f5f0ed387073

This enables us to see the log for any container by name.

Shortened docker ps output

Naturally, you’ll have to make certain you do not have numerous containers which match a name. If you do, then merely turn to the dkl command with a container ID.

An essential takeaway in the example above is that you can develop some quite effective aliases by integrating shell commands. We’ll see another example of this later on in this post, when we take a look at an alias for structure and publishing containers.

- Advertisement -

Get real time updates directly on you device, subscribe now.

- Advertisement -

- Advertisement -

Leave A Reply

Your email address will not be published.

x

We use cookies to give you the best online experience. By agreeing you accept the use of cookies in accordance with our cookie policy.

I accept I decline