FAQ
Q: How to customize a container's hostname?
A:
docker run -dit -p ${SSH_PORT}:22 \
-v /build:/work \
-v /home/:/home/ \
-v /nas:/HOUSE \
-v /etc/profile.d:/etc/profile.d \
-v /etc/group:/etc/group:ro \
-v /etc/passwd:/etc/passwd:ro \
-v /etc/shadow:/etc/shadow:ro \
-h ${CONTAINER_HOSTNAME} \
--name ${CONTAINER_NAME} ${IMAGE_ID} /bin/bash
The current best practice is:
docker system prune
Note the output from this command prior to accepting the consequences:
WARNING! This will remove:
- all stopped containers
- all networks not used by at least one container
- all dangling images
- all dangling build cache
Are you sure you want to continue? [y/N]
In other words, continuing with this command is permanent. Keep in mind that best practice is to treat stopped containers as ephemeral i.e. you should be designing your work with Docker to not keep these stopped containers around. You may want to consider using the--rm
flag at runtime if you are not actively debugging your containers.
Make sure you read this answer, re: VolumesYou may also be interested in this answer, if
docker system prune
does not work for you.
--------------------------------------
# Check all the docker container/images
docker
container ls
docker
image ls
#
Docker stop
docker
stop <container id>
#
Docker delete
docker
rm <container id>
#Docker
run
docker
run <container id>
--------------------------------------
#
Load docker image
docker
load --input <xxx>.tar.gz
#
change image name (optional)
docker
image tag <docker image id> <image_name>:<version>
ex:
docker
image tag b9ffda36b031 build_sa525m_env:latest
#
run container
./execute.sh
-p 1234 -n <container name> -I <container id>