Container 的子部分
CheatShett
- remove specific image
podman rmi <$image_id>
- remove all
<none>
images
podman rmi `podamn images | grep '<none>' | awk '{print $3}'`
- remove all stopped containers
podman container prune
- remove all docker images not used
podman image prune
- find ip address of a container
podman inspect --format='{{.NetworkSettings.IPAddress}}' minio-server
- exec into container
podman run -it <$container_id> /bin/bash
- run with environment
podman run -d --replace
-p 18123:8123 -p 19000:9000 \
--name clickhouse-server \
-e ALLOW_EMPTY_PASSWORD=yes \
--ulimit nofile=262144:262144 \
quay.m.daocloud.io/kryptonite/clickhouse-docker-rootless:20.9.3.45
--ulimit nofile=262144:262144
: 262144 is the maximum users process or for showing maximum user process limit for the logged-in user
ulimit
is admin access required Linux shell command which is used to see, set, or limit the resource usage of the current user. It is used to return the number of open file descriptors for each process. It is also used to set restrictions on the resources used by a process.
- login registry
podman login --tls-verify=false --username=ascm-org-1710208820455 cr.registry.res.cloud.zhejianglab.com -p 'xxxx'
- tag image
podman tag 76fdac66291c cr.registry.res.cloud.zhejianglab.com/ay-dev/datahub-s3-fits:1.0.0
- push image
podman push cr.registry.res.cloud.zhejianglab.com/ay-dev/datahub-s3-fits:1.0.0
- remove specific image
docker rmi <$image_id>
- remove all
<none>
images
docker rmi `docker images | grep '<none>' | awk '{print $3}'`
- remove all stopped containers
docker container prune
- remove all docker images not used
docker image prune
- find ip address of a container
docker inspect --format='{{.NetworkSettings.IPAddress}}' minio-server
- exec into container
docker exec -it <$container_id> /bin/bash
- run with environment
docker run -d --replace -p 18123:8123 -p 19000:9000 --name clickhouse-server -e ALLOW_EMPTY_PASSWORD=yes --ulimit nofile=262144:262144 quay.m.daocloud.io/kryptonite/clickhouse-docker-rootless:20.9.3.45
--ulimit nofile=262144:262144
: sssss
copy file
Copy a local file into container
docker cp ./some_file CONTAINER:/work
or copy files from container to local path
docker cp CONTAINER:/var/logs/ /tmp/app_logs
load a volume
docker run --rm \
--entrypoint bash \
-v $PWD/data:/app:ro \
-it docker.io/minio/mc:latest \
-c "mc --insecure alias set minio https://oss-cn-hangzhou-zjy-d01-a.ops.cloud.zhejianglab.com/ g83B2sji1CbAfjQO 2h8NisFRELiwOn41iXc6sgufED1n1A \
&& mc --insecure ls minio/csst-prod/ \
&& mc --insecure mb --ignore-existing minio/csst-prod/crp-test \
&& mc --insecure cp /app/modify.pdf minio/csst-prod/crp-test/ \
&& mc --insecure ls --recursive minio/csst-prod/"
Template
Template 的子部分
DevContainer Template
DEV
DEV 的子部分
Devpod
Preliminary
Get provider config
# just copy ~/.kube/config
for example, the original config
apiVersion: v1
clusters:
- cluster:
certificate-authority: <$file_path>
extensions:
- extension:
provider: minikube.sigs.k8s.io
version: v1.33.0
name: cluster_info
server: https://<$minikube_ip>:8443
name: minikube
contexts:
- context:
cluster: minikube
extensions:
- extension:
provider: minikube.sigs.k8s.io
version: v1.33.0
name: context_info
namespace: default
user: minikube
name: minikube
current-context: minikube
kind: Config
preferences: {}
users:
- name: minikube
user:
client-certificate: <$file_path>
client-key: <$file_path>
you need to rename clusters.cluster.certificate-authority
, clusters.cluster.server
, users.user.client-certificate
, users.user.client-key
.
clusters.cluster.certificate-authority -> clusters.cluster.certificate-authority-data
clusters.cluster.server -> clusters.cluster.server-data
users.user.client-certificate -> users.user.client-certificate-data
users.user.client-key -> users.user.client-key-data
the data you paste after each key should be base64
cat <$file_path> | base64
then we should forward minikube port in your own pc
#where you host minikube
MACHINE_IP_ADDRESS=10.200.60.102
USER=ayay
MINIKUBE_IP_ADDRESS=$(ssh -o 'UserKnownHostsFile /dev/null' $USER@$MACHINE_IP_ADDRESS '$HOME/bin/minikube ip')
ssh -o 'UserKnownHostsFile /dev/null' $USER@$MACHINE_IP_ADDRESS -L "*:8443:$MINIKUBE_IP_ADDRESS:8443" -N -f
then, modified config file should be look like this:
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: xxxxxxxxxxxxxx
extensions:
- extension:
provider: minikube.sigs.k8s.io
version: v1.33.0
name: cluster_info
server: https://127.0.0.1:8443
name: minikube
contexts:
- context:
cluster: minikube
extensions:
- extension:
provider: minikube.sigs.k8s.io
version: v1.33.0
name: context_info
namespace: default
user: minikube
name: minikube
current-context: minikube
kind: Config
preferences: {}
users:
- name: minikube
user:
client-certificate: xxxxxxxxxxxx
client-key: xxxxxxxxxxxxxxxx
Create workspace
- get git repo link
- choose appropriate provider
- choose ide type and version
- and go!
Useful Command
download kubectl binary
MIRROR="files.m.daocloud.io/"
VERSION=$(curl -L -s https://${MIRROR}dl.k8s.io/release/stable.txt)
[ $(uname -m) = x86_64 ] && curl -sSLo kubectl "https://${MIRROR}dl.k8s.io/release/${VERSION}/bin/linux/amd64/kubectl"
[ $(uname -m) = aarch64 ] && curl -sSLo kubectl "https://${MIRROR}dl.k8s.io/release/${VERSION}/bin/linux/arm64/kubectl"
chmod u+x kubectl
mkdir -p ${HOME}/bin
mv -f kubectl ${HOME}/bin
Everything works fine.
when you in pod, and using kubectl you should change clusters.cluster.server
in ~/.kube/config
to https://<$minikube_ip>:8443
download argocd binary
MIRROR="files.m.daocloud.io/"
VERSION=v2.9.3
[ $(uname -m) = x86_64 ] && curl -sSLo argocd "https://${MIRROR}github.com/argoproj/argo-cd/releases/download/${VERSION}/argocd-linux-amd64"
[ $(uname -m) = aarch64 ] && curl -sSLo argocd "https://${MIRROR}github.com/argoproj/argo-cd/releases/download/${VERSION}/argocd-linux-arm64"
chmod u+x argocd
mkdir -p ${HOME}/bin
mv -f argocd ${HOME}/bin
exec into devpod
kubectl -n devpod exec -it <$resource_id> -c devpod -- bin/bash
add DNS item
10.102.1.52 gitee.zhejianglab.com