- March 3, 2016
Installing Docker and Learning Common CommandsMarch 3, 2016
So we’ve talked a bit about containers, what they are, their benefits and some cool technologies that can augment them. Now we’re going to show you how to get up and running with Docker, and some basic commands on how to use it. You can use any cloud provider of your choice for your Virtual Machine. In this blog, we will be using an AWS Ec2 Instance to demonstrate. We’re going to assume that you are familiar with Amazon Web Services (AWS) and navigating within it. Ready to get started installing Docker?
Step 1: Login to AWS and launch a new EC2 instance. The AMI we will be using for this blog will be an Ubuntu Server 14.04 AMI in the US West Oregon Region (ami-29ebb519).
Step 2: Configure your security groups to allow SSH access from your External IP address, as well as All Traffic inbound over port 80.
Step 3: SSH into your EC2 instance and run the following command to install Docker on Ubuntu Server 14.04
# For Ubuntu 14.04 AMI
Step 4: Verify Docker installed correctly by running the below command. You should see no containers running at this time.
Common Docker Commands
Now that we have installed Docker, here is a list of some common Docker commands that will come in handy. We have given a brief description of what each does.
$ docker psShows a list of running Docker containers
$ docker imagesShows a list of Docker images on your server
$ docker stop <container_name> # can also be <container_id>Stops the specified container
$ docker start <container_name> # can also be <container_id>Starts the specified container
$ docker rm <container_name> # can also be <container_id>Removes the specified container
$ docker rmi <container_name> # example: redapt/redapt-demo:latestRemoves the specified Docker image
$ docker run
redapt/redapt-demo:latest # use the ‘Docker run help’ command for a list of flagsRuns the specified Docker image
$ docker run –name redapt-demo -d -p 80:80 –restart=always redapt/redapt-demo:latestRuns the specified Docker image with some common flags.
$ docker build -t redapt/redapt-demo:latest .Assuming you’re in a directory where a ‘Dockerfile’ is located. The above command will build an image based on the source code within the Dockerfile (explained more later).
You now know how to install docker, and have learned some basic commands on how to use it. This is the first step for getting your application containerized. Stayed tuned for part II in next week’s post where we dive into more technical detail for Dockerizing Your App!
Want to get started containerizing your apps? Reach out to the Redapt Cloud team today