1. Home
  2. Training Library
  3. Containers
  4. Courses
  5. Getting started with Docker

Docker Commands

Contents

keyboard_tab
Introduction
1
What is Docker?
PREVIEW2m 42s
Start course
Overview
Difficulty
Beginner
Duration
42m
Students
2974
Description

It's hardly an exaggeration to say that there hasn't been an innovation in app development and deployment over the past year or two that's been bigger than Docker. The open source platform for building, shipping, and running distributed applications in isolated virtual containers has literally changed the very fabric of the cloud. Thanks to Docker, software developers can reliably create and deploy applications with all their dependencies in Docker images that can be made available to anybody, and launched in seconds.

This introductory course, crafted by the expert Linux System Administrator David Clinton, will teach you everything you need to know to get started with Docker: What is the LXC software that it's built upon? How is it different from traditional virtualization technologies? How you can install and run it on your machine? By the end of this course, you'll have all the basic tools you'll need to run simple Docker applications.

Who should take this course

Being an introductory course, no previous knowledge of the software is needed. Nevertheless, you will definitely need at least some experience with the Linux Command Line Interface. Also, some familiarity with the Linux file system, kernel and networking basics might came in handy for some lectures.

Do you have questions on this course? Contact our cloud experts in our community forum.

Transcript

Hi, and welcome to CloudAcademy.com's video series on Docker the development oriented virtualization service. In this video, we're going to talk about Docker syntax. That is the, some basic Docker commands that can be used to manipulate and function within the Docker environment, which hopefully will give you a bit of an overview as to how syntax works with Docker in general.

To use commands in the Docker environment you have to be sudo, you have to have root privilege on your system, the host system, and you have to type "docker" to let your system know that you're going to be working within the Docker environment and then the command, whatever the command might be.

Docker commands overview

In the case of "ps," that is the command that will list all Docker processes or Docker images that are on the system that are running on the system. If you add "-a," it will also list those processes that exist on the system even if they've stopped. In this case, there's quite a list. They're all based on the same basic image. But nonetheless we've opened and closed or started and stopped a dozen or two images in the course of our recent work.

To start an image you could type "sudo docker start." And then the container ID of the particular image you're after. Let's run "ps" again this time without the "-a" to see if this instance is actually running now. In fact, it is.

You can also run "restart" to restart the container if there's some change you've made that requires a restart or something's become a little corrupted and could use a restart. You can copy files or directories from within a container to your host as an example. So you might type "sudo docker cp," which is the normal Unix command for copy. And then the container ID, colon and then the absolute address of the file that you're going after within the container. So in our case let's try etc/network/interfaces which is the file that contains the configuration for the network manager. And now the location on the host that you'd like to copy to. So let's say just to the temp, the TMP directory on the host. So with this we will copy the file interfaces from our Docker container to the temp directory on the host.

Docker logs, diff and pull commands

You can view some logged information from your container using the logs command "sudo docker logs," followed by the container ID. And some basic containers start up and stop information without a whole lot of supporting information is displayed. But there are arguments you can add to this command that will enhance the level of information available.

You can track changes made on your Docker container with the command "diff." That will display all the changes made from the base image to the state of the container as it stands now. "A" represents anything added, a file or contents of a file that are added. "D" would represent a file that had been deleted and "C" is a file that's been changed.

A command you'll probably use a great deal is "pull," "sudo docker pull" and the name of an image you'd like to pull from the Docker repository. Let's say, "Deviant." If we would pull deviant right now, it would take quite some time to download and install. But once that's done we could then load images using the deviant image just as we have until now been loading images using the Ubuntu image.

About the Author
Avatar
David Clinton
Linux SysAdmin
Students
11646
Courses
12
Learning Paths
4

David taught high school for twenty years, worked as a Linux system administrator for five years, and has been writing since he could hold a crayon between his fingers. His childhood bedroom wall has since been repainted.

Having worked directly with all kinds of technology, David derives great pleasure from completing projects that draw on as many tools from his toolkit as possible.

Besides being a Linux system administrator with a strong focus on virtualization and security tools, David writes technical documentation and user guides, and creates technology training videos.

His favorite technology tool is the one that should be just about ready for release tomorrow. Or Thursday.