# Alpine (fast)
docker pull alpine
docker run -it --name=alpine_container alpine
# Ubuntu
echo "from ubuntu:latest" > dockerfile_bash
docker build -t bash_image -f dockerfile_bash .
docker run -it --name=bash_container bash_image
docker restart bash_container
docker exec -it bash_container bash
docker cp bash_test.sh bash_container:bash_test.sh
docker container ls -a
docker ps -a
su - www-data -s /bin/bashdocker rm $(docker ps -a -q)
docker rmi $(docker images -q)From: https://stackoverflow.com/questions/29599632/container-is-not-running
docker pull debian
docker run -t -d --name my_debian debian
e7672d54b0c2
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e7672d54b0c2 debian "bash" 3 minutes ago Up 3 minutes my_debian
#now you can execute command on the container
docker exec -it my_debian bash
root@e7672d54b0c2:/
# docker inspect returns a JSON object with a lot of info about the container, and in particular whether the container is currently running or not. The -f flag lets you easily extract the bits needed:
docker inspect -f "{{.State.Running}}" $CONTAINER_IDdocker topdocker cp foo.txt mycontainer:/foo.txtdocker ps -adocker stop $(docker ps -a -q)From: https://docs.docker.com/engine/reference/commandline/run/