Skip to content

Instantly share code, notes, and snippets.

@loujaybee
Last active June 19, 2022 11:59
Show Gist options
  • Save loujaybee/9fc041a5aa5f22103f4a1f3b6265feec to your computer and use it in GitHub Desktop.
Save loujaybee/9fc041a5aa5f22103f4a1f3b6265feec to your computer and use it in GitHub Desktop.
ansible
---
hosts: all
tasks:
- copy: ~
dest: "."
name: "copy Dockerfile into remote machine"
src: Dockerfile
- copy: .
src: webapp.war
dest: "."
name: "copy .war file into remote machine"
- command: "Docker stop finalcontainer"
ignore_errors: true
name: "stop the running container"
- command: "Docker rm finalcontainer"
ignore_errors: true
name: "remove the running container"
- command: "Dockerfile rmi testimage"
ignore_errors: true
name: "remove the running image"
- command: "Docker build -t testimage ."
name: "create testimage from Dockerfile"
- command: "Docker run -d -p 8080:8080 --name finalcontainer testimage"
name: "create and run container"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment