Skip to content

Commit

Permalink
Created new blog for docker commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Xithrius committed Jan 23, 2023
1 parent dca85de commit fc9d2c9
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions site/posts/neat-docker-commands.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
title: "Neat Docker commands"
excerpt: "Docker does the do."
date: "2022-01-22"
---

With the docker command below, you're able to create an Ubuntu shell with the files contained in the current working directory. This is neat for quickly testing out something like a shell script on a different version of Ubuntu, or just seeing if your C program compiles at all somewhere else.

```
docker run -it -v "$PWD:/workspace" -w /workspace ubuntu:20.04 /bin/bash
```

Another neat command gives you a `psql` shell in a postgres container. For example, if we were to have the `docker-compose.yml` file below,

```yml
version: "3.7"

services:
postgres:
container_name: a-postgres-container

image: postgres:latest

environment:
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}

ports:
- "5432:5432"
```

Then we'd be able to execute what's below to be able to get that `psql` shell, as the user `postgres`.

```
docker exec -it a-postgres-container psql -U postgres
```

Not all containers support this, but sometimes you're able to create a bash shell within a container with the following, where `a-container` is the name of the container.

```
docker exec -it a-container /bin/bash
```

1 comment on commit fc9d2c9

@vercel
Copy link

@vercel vercel bot commented on fc9d2c9 Jan 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

xithrius-cloud – ./

xithrius-cloud-git-main-xithrius.vercel.app
xithrius-cloud-xithrius.vercel.app
xithrius.cloud

Please sign in to comment.