Skip to content

Instantly share code, notes, and snippets.

@fthamura
Last active January 1, 2016 01:48
Show Gist options
  • Save fthamura/197421ce19d0cb19bfa0 to your computer and use it in GitHub Desktop.
Save fthamura/197421ce19d0cb19bfa0 to your computer and use it in GitHub Desktop.
docker pull centos:7
- List locally, installed images
docker images
- Show all images, including itermmediate
docker images -a
- Run a linux command inside a docker container:
docker run --rm centos:7 echo "hello world"
- run a shell inside a docker container:
docker run -it --rm centos:7 bash
- run several cmd
hostname -f
cat /etc/hosts
ps aux
yum -y install vim
ip a
- case
rm -fr /usr/sbin
rm -fr /usr/bin
ls
exit
- solution to recover
docker run -it --rm centos:7 bash
- run with delete container after stop (-rm)
docker run --rm -p 8888:8080 tomcat:8.0
- from browser
http://localhost:8888
- troubleshoot
docker ps
- login to run container using container id
docker exec -it <container_id> bash
- Nor should we have any stopped containers:
docker ps -a
- running tomcat with name "tomcat8"
docker run -d --name="tomcat8" -p 8888:8080 tomcat:8.0
- view log tomcat8
docker logs tomcat8
- run as daemon
docker top tomcat8
- inspect container https://docs.docker.com/reference/commandline/inspect/
docker inspect tomcat8
- stop tomcat8
docker stop tomcat8
- remove tomcat8
docker rm tomcat8
- docker machine run lab
docker-machine run lab
- stop docker service
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment