-
Notifications
You must be signed in to change notification settings - Fork 0
How to's
$ docker run -it --rm [image] [program]
Note: The command starts a container based on [image] and runs [program] in interactive mode (-it). When the container is stopped, all the state will be removed (--rm).
$ docker pull [image]
$ docker push [image]
$ docker build -t image-name .
Note: . indicates that the Dockerfile is in the current directory.
$ docker images
$ docker rmi [image ID or name]
Note: When an image is removed, all related containers are removed as well.
$ docker rmi $(docker images --quiet --filter "dangling=true")
Create a Dockerfile extending an existing image and add some layers to it by copying files (using the ADD command), executing commands (using the CMD command), etc. Dockerfile:
FROM jboss/wildfly
ADD standalone-custom.xml /opt/wildfly/standalone/configuration/
CMD ["/opt/wildfly/bin/standalone.sh", "-c", "standalone-custom.xml", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0"]
$ docker ps
Note: docker ps -a lists all containers that have been exited as well.
$ docker inspect [container name or id]
Note: Retrieve a container name or id by running docker ps.
$ docker kill [container name or id]
Note: Retrieve a container name or id by running docker ps.
$ docker rm [container name or id]
$ docker ps
$ docker inspect [container name or ID]
Note: Look for IPAddress on the container JSON data.
$ docker run -it --rm -p 8080:8080 jboss/wildfly
Note: You may add as many -p parameters as needed.
$ docker exec -i -t [container name or ID] [program]
See Dockerfile Best Practices.
$ docker run -it --rm -p 8080:8080 -p 9990:9990 jboss/wildfly
Deploying an app using the Deployment scanner
Dockerfile:
FROM jboss/wildfly
ADD application.war /opt/jboss/wildfly/standalone/deployments/