Git Product home page Git Product logo

docker-learning's Introduction

docker-learning

Learning how to Docker

Useful Links

AEM Docker Resources/Examples:

Useful Commands

# see which version of docker you have installed
docker --version

# will attempt to run a docker image called hello-world and download from a repo if it doesn't exist: https://hub.docker.com/_/hello-world
docker run hello-world

# Monitor running and exited docker instances
docker ps -a

# start a docker container w/ custom name using the 'hello-world' container type
docker run --name zaps-hello-world hello-world

# Assign name and allocate pseudo-TTY (--name, -it)
# Then get the ubuntu container from the docker hub
# Then open bash in that ubuntu container once it has been downloaded
# https://hub.docker.com/_/ubuntu
docker run -it --name my-linux-container ubuntu bash

# Terminal into a running container
docker exec -it [container-id] bash

# exit a running image
exit

# See all downloaded/installed docker images
docker images

# Remove any docker images which have exited (note, this will *not* remove the downloaded docker images)
docker rm $(docker ps -a -f status=exited -q)

# Link local data to a running container, and remove it from the docker process list once it has exited
docker run -it --name my-linux-container --rm -v /Local/Data/Path:/container/data/path ubuntu bash

docker run -it --name my-linux-container --rm -v '/c/Users/SnappyZappy/Desktop/Doom Shit':/snappy-zappy ubuntu bash

Make Custom Image

# Every container is built upon other containers (public)
# Start with the public ubuntu container
FROM ubuntu
CMD echo "Hello Jonny"
cd path/to/Dockerfile &&
# Build your custom image using the Dockerfile created above (. refers to the Dockerfile)
docker build -t zaps-ubuntu-image .

You should get the following:

Sending build context to Docker daemon  61.95kB
# Step 1 is grabbing Ubuntu
Step 1/2 : FROM ubuntu
 ---> a2a15febcdf3
 # Step 2: Here's our custom command from our Dockerfile
Step 2/2 : CMD echo "Hello Jonny"
 ---> Running in d17512516c6b
Removing intermediate container d17512516c6b
 ---> e8bde1b99708
Successfully built e8bde1b99708
Successfully tagged zaps-ubuntu-image:latest

Now lets add some software to the ubuntu image by modifying the Dockerfile

FROM ubuntu
RUN apt-get upgrade && apt-get update && apt-get install -y python3

Now rebuild the image:

docker build -t zaps-ubuntu-image .

Then run the image:

docker run -it zaps-ubuntu-image

Once the image is online, you should be able to run python 3 from the cmd line

Cleanup Images

# Stop all running images
docker stop $(docker ps -q)

https://www.digitalocean.com/community/tutorials/how-to-remove-docker-images-containers-and-volumes

docker-learning's People

Contributors

zaprowsdower avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.