Skip to content

Instantly share code, notes, and snippets.

@joshuaaguilar20
Created January 28, 2019 22:38
Show Gist options
  • Save joshuaaguilar20/9a5c048b75f20a8f9ffd8df3ce99e3dc to your computer and use it in GitHub Desktop.
Save joshuaaguilar20/9a5c048b75f20a8f9ffd8df3ce99e3dc to your computer and use it in GitHub Desktop.
DockerBasics
Docker Basic
Sudo Docker run --ImageName
Sudo Docker Ps (shows all current running docker containers)
` Also Gets Container Id.
Docker ps --all
docker create fileName
-creates container
to start container must run
docker start -a (containerId)
-a makes docker watch for output and print to machine terminal
docker system prune
WARNING! This will remove:
- all stopped containers
- all networks not used by at least one container
- all dangling images
- all build cache
docker logs - Give records from containers
docker- stop ( stops container on own time)
docker-kill (kills it ASAP no questions asked
sudo docker redis-server ( will Start Running Server, but how will we issue commands
if that terminal is already running?
We Will Run Command
Docker ps to get ID of redis server running in docker
We will then run
~$ docker exec -it 80ad76b6ab42 redis-cli
-it Flag Very Important in the world of docker
is two flags -i -t
-i attaches terminal to standard Inn Redis CLI
-t Flag Makes sure all the text entered is formatted and a little more behind the scenes
How to Open Shell in Running Container
sudo run docker ps
get id oc container u want
docker exec -it (id) sh
sometimes you can use bash as well
Docker run -it sh
Empty Shell to poke around
sudo docker run -it (imageName) sh
downside- Can not run anyother process
may want to have running process and attach shell to that process with exec command*
See above*
If you run two containers of the same instance such as busybox ETC
they are separate unless connected. each instance has different files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment