-
Notifications
You must be signed in to change notification settings - Fork 1
/
podman-commands.txt
123 lines (87 loc) · 3.35 KB
/
podman-commands.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# https://podman-desktop.io/docs/onboarding-for-containers/installing-podman
# Initialize a Podman machine
podman machine init
# Check the socket Podman is using
podman machine inspect --format '{{.ConnectionInfo.PodmanSocket.Path}}'
# Set the DOCKER_HOST environment variable to the Podman socket location. This enables the use of Docker commands with Podman
export DOCKER_HOST='unix:///$HOME/.local/share/containers/podman/machine/qemu/podman.sock'
# Start Podman machine
podman machine start
# Stop Podman machine
podman machine stop
### Dockerfile ###
# Build image from Dockerfile in directory
# name image: -t <image_name>
# podman build -t <image_name> .
podman build -t fso-hello-world .
podman build . -t hello-front
# Run container from image
# podman run <image-name>
podman run fso-hello-world
# Run container from image and use its shell
podman run -it hello-front bash
# Build image from Dockerfile in directory
# podman build -t <image_name> .
podman build -t express-server .
# Run container from image, connect computer port to container express app port
# podman run -p <host-port>:<application-port> <image-name>
podman run -p 3123:3000 express-server
# -f tells podman which file to use. it otherwise defaults to Dockerfile
podman build -f ./dev.Dockerfile -t todo-front-dev .
# pwd is the current directory
# -v maps the current directory to the inside of the container
podman run -p 3004:3004 -v "$(pwd):/usr/src/app/" todo-front-dev
podman exec fso-react-app-dev npm install axios
# List running containers
podman container ls
# Stop a running container
# podman kill <container_name>
podman kill great_kalam
# Delete a running container
# podman container rm <container_name>
podman container rm great_kalam
### docker-compose.yml ###
# Build and run image from docker-compose.yml
podman compose up
# Rebuild image from docker-compose.yml
podman compose up --build
# Run the application in the background
# -d for detached
podman compose up -d
# Close application
podman compose down
# Create an Express server that runs in port 3000, then run it:
podman build -t express-server . && podman run -p 3000:3000 express-server
# By creating docker-compose.yml to go with the Dockerfile, instead of running the code above^, simply run:
podman compose up
# Pull hello-world image from Docker Hub and run it
podman run index.docker.io/library/hello-world:latest
# Pull hello-world image from https://quay.io/ and run it
podman run hello-world
# the flag -d runs container in detached mode (the terminal won't show that it's running)
podman container run -d docker.io/library/nginx
# restart with the -p flag to have our browser access it
podman container run -d -p 8080:80 docker.io/library/nginx
# The docker exec command runs a new command in a running container
podman exec
# the flags -it will ensure that we can interact with the container
podman exec -it <container_name> bash
# Entering the container and using mongosh
podman exec -it todo-backend-mongo-1 mongosh -u dockeruser -p dockerpassword
# show databases with mongosh
show dbs
# use the correct database with mongosh
use docker_mongo_database
# show collections with mongosh
show collections
# access the data in a collection with mongosh
db.todos.find({})
# Creating a todo using mongosh
db.todos.insertOne(
{
text: "Increase the number of todos",
done: false,
}
)
# leave container mongosh
quit