Skip to content

frank/docker_minimal_example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A minimal Docker example

This repo contains the minimal working example for working with docker according to my personal needs. In order to run it, first install Docker. Note I ran this on Ubuntu, although the procedure should work for Mac as well.

  1. Run the command:
frank@pc:~/Documents/docker_minimal_example$ docker build -t image_name .

What this command is doing is building the dockerfile into a docker image. This image is not yet a container, but now any component that needed downloading or installing is ready. Two things should be noted about this command. One is the -t image_name flag, which specifies (unsurprisingly) that the name of this particular built image is "image_name". The . at the end of the command specifies where docker should look for the dockerfile. This is also the working directory for any command issued within the dockerfile, like COPY.

  1. Now you have a built image. You can see that it's there by issuing:
frank@pc:~/Documents/docker_minimal_example$ docker images

This listing will also show the image's ID. At any point you can remove an image by issuing:

frank@pc:~/Documents/docker_minimal_example$ docker rmi [IMAGE_ID]
  1. Now you're ready to run the image by making it into a container. The container exists as soon as its process terminates. Do this by issuing:
frank@pc:~/Documents/docker_minimal_example$ docker run -v ~/Documents/docker_minimal_example:/app image_name

This command is doing two things. By using the -v flag, it's mounting the host directory ~/Documents/docker_minimal_example onto the container directory /app. This means that now our script can read the input file located in ./data for instance, as well as write into a new output file in ./data.

  1. If at any point you wanted to delete this container (which you want to do when deleting an image that the container is based on), you can start by listing all of your containers by issuing:
frank@pc:~/Documents/docker_minimal_example$ docker ps -a

Then in a similar fashion as for deleting images, run:

frank@pc:~/Documents/docker_minimal_example$ docker rm [CONTAINER_ID]

About

A minimal example for working with docker

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published