docker container run -it jboss/wildfly
docker container run -d jboss/wildfly
docker container ls
docker container stop {name}
docker container rm {name}
docker container run -d --name web jboss/wildfly
docker container ls
docker container rm -f web
docker container run -it --name web jboss/wildfly bash
docker container run -d --name web -P jboss/wildfly
docker container run ls
docker container logs web
Access WildFly home page in browser on the exposed port
docker container stop web
docker container rm web
docker container run -d --name web -p 8080:8080 jboss/wildfly
docker container logs web
Access WildFly home page in browser on 8080
docker container rm -f web
docker container run -d --name web -p 8080:8080 -v `pwd`/webapp.war:/opt/jboss/wildfly/standalone/deployments/webapp.war jboss/wildfly
docker container logs web -f
curl http://localhost:8080/webapp/resources/persons
-
Dockerfile syntax
-
Create a new directory
-
Explain build context
FROM ubuntu
CMD echo "Hello world"
-
Build image:
docker image build -t helloworld .
-
Explain
.dockerignore
-
List image:
docker image ls
-
History of image:
docker image history helloworld
-
Run container:
docker container run helloworld
-
Explain
--compress
-
Explain
--squash
FROM openjdk
CMD java -version
-
Build image:
docker image build -t hellojava .
-
List image and show the size:
docker image ls
-
Run container:
docker container run hellojava
FROM openjdk:jdk-alpine
CMD java -version
-
Build image:
docker image build -t hellojava:2 .
-
Talk about image tagging
-
List image and show/compare the size:
docker image ls
-
Run container:
docker container run hellojava:2
-
Explain
COPY
vsADD
FROM jboss/wildfly
COPY webapp.war /opt/jboss/wildfly/standalone/deployments/webapp.war
-
Build image:
docker image build -t helloweb .
-
Run container:
docker container run -p 8080:8080 -d helloweb
-
Access application:
curl http://localhost:8080/webapp/resources/persons
FROM openjdk:jdk-alpine
COPY myapp/target/myapp-1.0-SNAPSHOT.jar /deployments/
CMD java -jar /deployments/myapp-1.0-SNAPSHOT.jar
-
Create JAR file:
mvn -f myapp/pom.xml clean package
-
Build image:
docker image build -t hellojava:3 .
-
Run container:
docker container run hellojava:3
-
Change Java application (change "Hello" to "Howdy")
-
Create new JAR file using
mvn -f myapp/pom.xml clean package
-
Build new Docker image:
docker image build -t hellojava:4 .
-
Run new Docker container:
docker container run hellojava:4
-
Show updated changes
-
Run using CLI:
mvn clean package exec:java
-
Show
pom.xml
and explain DMP -
Build image:
mvn package -Pdocker
-
Show image:
docker image ls
-
Run container:
mvn install -Pdocker
-
Run using CLI:
./gradlew build run
-
Show
build.gradle
and explain Docker Gradle Plugin -
Build image:
./gradlew dockerBuildImage
-
Show image:
docker image ls
-
Run container:
./gradlew startContainer
-
Show tags at https://hub.docker.com/_/openjdk/
-
Docker image name format:
<registry>/repo_name:tag
-
Default value of
<registry>
isdocker.io
-
-
docker image rm -f $(docker image ls -qa)
-
docker container rm -f $(docker container ls -aq)
-
Build image:
docker image build .
-
List image: Use
docker image ls
to show the list of images, particular<none>:<none>
for this image -
Run container:
docker container run <image-id>
, have no name
-
Build image:
docker image build -t helloworld .
-
List image:
docker image ls
, show default<none>:<none>
is gone,latest
tag is created -
Run container:
docker container run helloworld
anddocker container run helloworld:latest
-
Remove all containers:
docker container rm -f $(docker container ls -aq)
-
Remove image with
latest
tag:docker image rm helloworld:latest
-
Build image:
docker image build -t helloworld:1 .
-
List image:
docker image ls
, show nolatest
tag -
Run container:
docker container run helloworld:1
-
Run
latest
container:docker container run helloworld
anddocker container run helloworld:latest
-
Tag image:
docker image tag helloworld:1 helloworld:latest
-
List images:
docker image ls
, show both tags are available -
Run
latest
container (now works):docker container run helloworld
anddocker container run helloworld:latest
Use Dockerfile:
FROM ubuntu:latest
CMD echo "This is v2"
-
Build image:
docker image build -t helloworld:2 .
-
Run container:
docker container run helloworld
shows v1 -
Tag v2 to
latest
:docker image tag helloworld:2 helloworld:latest
-
Run container:
docker container run helloworld
shows v2 now
-
Push the image without namespace and show the error:
docker image push helloworld:latest
-
Tag image:
docker image tag helloworld:2 arungupta/helloworld:latest
-
Login to Docker:
docker login
-
Push to Docker Hub:
docker image push arungupta/helloworld:latest
-
Push to local registry
-
Run registry:
docker container run -d -p 5000:5000 --restart always --name registry registry:2.6.0
-
Tag image for local registry:
docker image tag helloworld:latest localhost:5000/arungupta/helloworld:latest
-
Use
docker image ls
to show the list of images -
Push to local registry:
docker image push localhost:5000/arungupta/helloworld:latest
-