Independent Tech & Cryptocurrency News
Bitcoin
$6,350.38
-13.77
(-0.22%)
Ethereum
$207.39
-2.12
(-1.01%)
Ripple
$0.51
-0.01
(-1.54%)
Litecoin
$49.66
-0.98
(-1.94%)
EOS
$5.31
-0.12
(-2.21%)
Cardano
$0.07
-0
(-3.24%)
Stellar
$0.25
-0.02
(-6.37%)
NEO
$15.51
-0.21
(-1.34%)
NEM
$0.11
-0.01
(-6.66%)
DigitalCash
$163.12
-1.63
(-0.99%)
Tether
$0.97
-0.01
(-0.59%)
Binance Coin
$9.20
QTUM
$3.67
-0.06
(-1.61%)
Verge
$0.01
-0
(-2.74%)
Ontology
$1.55
0
(0%)
ZCash
$129.49
-5.62
(-4.16%)
Steem
$0.72

Handy Docker Aliases – Hacker Noon

0


Now on to our aliases… this better be good right?

The first aliases we’ll look at simply provide abbreviations for common docker commands.

Right off the bat, consider the time saving every time you replace docker with dk for commands like docker ps or when working with services and using dks for docker service commands like docker service ls. The savings of typing dks ls add up!

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

docker logs b7a8 becomes dkl b7a8

Use dklfto follow a log. So rather than docker logs -f b7a8 you can simply use dklf b7a8

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

It evaluates the piped commands within the backticks (`) and utilizes the result as a parameter to the docker logs command. The grep command uses the first parameter to filter the results of the docker ps command. And finally, the awk command takes the first field of the output as the value parameter.

Ok, that might be confusing. Let’s take a closer look.

The docker ps command returns a list of running containers.

Abbreviated docker ps output

And docker ps | grep redis returns:

Abbreviated output

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

This allows us to view the log for any container by name.

Abbreviated docker ps output

Naturally, you’ll need to make sure you don’t have multiple containers which match a name. If you do, then simply resort to the dkl command with a container ID.

A key takeaway in the example above is that you can build some pretty powerful aliases by combining shell commands. We’ll see another example of this later in this post, when we look at an alias for building and publishing containers.



coindesk.com

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

Leave A Reply

Your email address will not be published.