InfoHeap
Tech tutorials, tips, tools and more
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search
  • Home
  • > Kubernetes

Mac – create a one container pod and get shell to it

on Dec 31, 2022

Steps to create a pod with nginx container and get shell to it:

  1. Create config file shell-demo.yaml
    apiVersion: v1
    kind: Pod
    metadata:
      name: shell-demo
    spec:
      volumes:
      - name: shared-data
        emptyDir: {}
      containers:
      - name: nginx
        image: nginx
        volumeMounts:
        - name: shared-data
          mountPath: /usr/share/nginx/html
      hostNetwork: true
      dnsPolicy: Default
  2. Create the pod
    kubectl apply -f shell-demo.yaml
  3. Get a shell to the running container (container name will be needed in case more than one containers in pod)
    kubectl exec --stdin --tty shell-demo -- /bin/bash
  4. Create a root page for nginx (in shell window)
    echo 'Hello shell demo' > /usr/share/nginx/html/index.html
  5. Install curl and test the site
    apt-get update
    apt-get install curl
    curl http://localhost/

    The output should show:
    Hello shell demo

Suggested posts:

  1. Run nginx in docker container
  2. Install nginx and php in docker ubuntu container
  3. Mac – docker sample – single container dev env – quick start
  4. Mac m1 – minikube – create multi node kubernetes cluster
  5. Jenkins execute shell – how to continue on error
  6. LXC (Linux Containers) – quick start tutorial on Ubuntu
  7. Mac terminal – how to close shell on exit
  8. Docker container – handy commands
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged Kubernetes, Mac Docker
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries

Copyright © 2023 InfoHeap.

Powered by WordPress