Docker snippet

Docker snippet

List old docker containers :

 docker ps --no-trunc -aq

Delete them :

docker rm `docker ps --no-trunc -aq`
Delete image :
docker rmi climz/apache
or with the id
docker rmi f8bfe5f3d6e8

Run docker with tty :
docker run -i -t ubuntu /bin/bash

Run docker container interactive with port redirect :
docker run -i -p 8000:80 -t djangosrv/latest /bin/bash
Create an image from a running container :
docker commit -m "Create nginx, uwsgi, supervisord server" -a "Julien"  3d1645041d69 climz/djangosrv:v1

DockerFile example

# This is a comment
FROM climz/djangosrv:v2
RUN apt-get update && apt-get install
ADD supervisord.conf /home/bada/mysite/supervisord.conf
CMD ["/usr/bin/supervisord"]
Create a container from a docker file
docker build -t climz/djangosrv:v2 .

Run docker container as daemon :

docker run -P -d climz/djangosrv:v3
-P redirect all expose port
-d daemonise

Connect to running docker

bash-4.4$ docker exec -it e38de44945ab /bin/bash

Leave a Reply

Your email address will not be published. Required fields are marked *