DEV Community

DevCorner
DevCorner

Posted on

Essential Maven, Docker, Kubernetes, and Helm Commands for Modern Development

Mastering the tools of modern software development is crucial for any backend developer. This blog post covers essential commands for Maven, Docker, Kubernetes, and Helm, often encountered in real-world development and deployment scenarios.


Maven Commands

Maven Command Description
mvn clean install -Dmaven.test.skip=true Generates a JAR file inside the target folder, skipping tests.
mvn spring-boot:run Starts a Spring Boot Maven project.
mvn spring-boot:build-image Generates a Docker image using Buildpacks without needing a Dockerfile.
mvn compile jib:dockerBuild Creates a Docker image using Google Jib without needing a Dockerfile.

Docker Commands

Docker Command Description
docker build . -t gavebegin/accounts:s4 Builds a Docker image from a Dockerfile.
docker run -p 8080:8080 gavebegin/accounts:s4 Runs a Docker container from a given image.
docker images Lists all Docker images.
docker image inspect image-id Displays detailed information about an image.
docker image rm image-id Removes an image.
docker image push docker.io/gavebegin/accounts:s4 Pushes an image to a registry.
docker image pull docker.io/gavebegin/accounts:s4 Pulls an image from a registry.
docker ps Lists running containers.
docker ps -a Lists all containers, including stopped ones.
docker container start container-id Starts a stopped container.
docker container pause container-id Pauses a container.
docker container unpause container-id Unpauses a container.
docker container stop container-id Stops a running container.
docker container kill container-id Kills a running container immediately.
docker container restart container-id Restarts a container.
docker container inspect container-id Inspects container details.
docker container logs container-id Fetches container logs.
docker container logs -f container-id Follows container logs.
docker container rm container-id Removes a container.
docker container prune Removes all stopped containers.
docker compose up Creates and starts containers using a docker-compose file.
docker compose down Stops and removes containers created via docker-compose.
docker compose start Starts containers defined in a docker-compose file.
docker run -p 3306:3306 --name accountsdb -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=accountsdb -d mysql Creates a MySQL container.
docker run -p 6379:6379 --name gavebeginredis -d redis Creates a Redis container.
docker run -p 8080:8080 -e KEYCLOAK_ADMIN=admin -e KEYCLOAK_ADMIN_PASSWORD=admin quay.io/keycloak/keycloak:22.0.3 start-dev Creates a Keycloak container.

Apache Benchmark (ab) Command

Command Description
ab -n 10 -c 2 -v 3 http://localhost:8072/gavebegin/cards/api/contact-info Load tests an API by sending 10 requests with concurrency level 2.

Kubernetes Commands

Kubernetes Command Description
kubectl apply -f filename Deploys resources defined in a YAML file.
kubectl get all Lists all resources in the cluster.
kubectl get pods Lists all pods.
kubectl get pod pod-id Describes a specific pod.
kubectl describe pod pod-id Shows detailed information about a pod.
kubectl delete pod pod-id Deletes a pod.
kubectl get services Lists all services.
kubectl get service service-id Describes a specific service.
kubectl describe service service-id Shows detailed information about a service.
kubectl get nodes Lists all nodes.
kubectl get node node-id Describes a specific node.
kubectl get replicasets Lists all replica sets.
kubectl get replicaset replicaset-id Describes a specific replica set.
kubectl get deployments Lists all deployments.
kubectl get deployment deployment-id Describes a specific deployment.
kubectl get configmaps Lists all ConfigMaps.
kubectl get configmap configmap-id Describes a specific ConfigMap.
kubectl get events --sort-by=.metadata.creationTimestamp Displays events sorted by creation time.
kubectl scale deployment accounts-deployment --replicas=1 Scales a deployment.
kubectl set image deployment gatewayserver-deployment gatewayserver=gavebegin/gatewayserver:s11 --record Updates a deployment's image.
kubectl rollout history deployment gatewayserver-deployment Shows rollout history of a deployment.
kubectl rollout undo deployment gatewayserver-deployment --to-revision=1 Rolls back to a specific revision.
kubectl get pvc Lists persistent volume claims (PVCs).
kubectl delete pvc data-happy-panda-mariadb-0 Deletes a PVC.

Helm Commands

Helm Command Description
helm create [NAME] Creates a new chart.
helm dependencies build Recompiles chart dependencies.
helm install [NAME] [CHART] Installs a chart.
helm upgrade [NAME] [CHART] Upgrades a release.
helm history [NAME] Shows revision history.
helm rollback [NAME] [REVISION] Rolls back a release.
helm uninstall [NAME] Uninstalls a release.
helm template [NAME] [CHART] Renders chart templates locally.
helm list Lists all Helm releases.

Mastering these commands will give you confidence in building, containerizing, deploying, and managing applications in production environments. Bookmark this page as a quick reference for your day-to-day development journey. Happy coding!

Top comments (0)