Skip to content

Instantly share code, notes, and snippets.

View rowend36's full-sized avatar
🎯
Focusing

Rowend Duke rowend36

🎯
Focusing
View GitHub Profile
@msrose
msrose / docker-cheatsheet.md
Last active June 27, 2023 10:33
Docker cheatsheet

Docker cheatsheet

This gist might help you answer the following questions:

  • How do I run a command inside a docker container?
  • Why isn't my docker container running?
  • Why is my docker container stopping right after I start it?

Most of the time when using docker, I want to get a shell inside a running container, either to see what's installed inside an image, or debug failing commands, or something else similar. I don't think this is the primary use case for the docker CLI, because it always takes a few different commands with flags that I always forget; before long, I find myself confused all over again as to how containers work and how to manipulate them with the CLI.

Here's the easiest CLI-only way I've found to pull an image, create a container from it, and run a terminal in that container. I've done my best to explain every command and flag so I'll never have to wonder again why my container seemed to stop immediately, or stop suddenly, or vanish off the face of the Earth.

@msrose
msrose / combining-git-repositories.md
Last active April 22, 2024 19:05
How to combine two git repositories.

Combining two git repositories

Use case: You have repository A with remote location rA, and repository B (which may or may not have remote location rB). You want to do one of two things:

  • preserve all commits of both repositories, but replace everything from A with the contents of B, and use rA as your remote location
  • actually combine the two repositories, as if they are two branches that you want to merge, using rA as the remote location

NB: Check out git subtree/git submodule and this Stack Overflow question before going through the steps below. This gist is just a record of how I solved this problem on my own one day.

Before starting, make sure your local and remote repositories are up-to-date with all changes you need. The following steps use the general idea of changing the remote origin and renaming the local master branch of one of the repos in order to combine the two master branches.