This Lesson is for Members

Subscribe today and get access to all lessons! Plus direct HD download for offline use, enhances transcripts, member comment forums, and iTunes "podcast" RSS feed. Level up your skills now!

Unlock This Lesson

Already subscribed? Sign In

Autoplay

    Run One-Off Docker Containers

    Mark ShustMark Shust

    You’ll often need to execute various administrative or maintenance tasks for your app, such as database migrations or arbitrary console commands.

    In this lesson, we will learn how to run arbitrary one-off commands as disposable Docker containers.

    Code

    Code

    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    Transcript

    Transcript

    Instructor: 00:00 Docker containers are cheap, meaning that they take very little disk space and memory to run, and they can be killed off and started very quickly and easily. This disposable nature makes it very easy to run isolated containers that can execute arbitrary tasks.

    00:16 Let's use Docker run with the -it flag and the --rm flag. We will run the Ubuntu instance and drop in a Bash. We are now at the Command prompt within the Ubuntu operating system, and can run any command that is available within Ubuntu. Let's exit the prompt.

    00:38 If we check the status of all containers, we can see that we don't have any. The --rm flag killed the container when we exited the process. We can also skip the Bash prompt and execute commands directly. Docker started the Ubuntu container, ran our LS command, displayed the output to standard out, exited Ubuntu, and then, killed off the container, all in less than a second.

    Discuss

    Discuss