-
-
Save philcrissman/fce852472475011ef5e881b2da0839bb to your computer and use it in GitHub Desktop.
Attach to a docker container with less typing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
class DockerAttacher | |
attr_reader :docker_container | |
def initialize(docker_container) | |
if docker_container.nil? | |
puts "Usage: dock [container_id]\nGet container id with `docker ps`" | |
else | |
@docker_container = docker_container | |
end | |
end | |
def attach! | |
return unless docker_container | |
attach_to_docker_container | |
end | |
private | |
def attach_to_docker_container | |
exec("docker exec -it #{docker_container} /bin/bash") | |
end | |
end | |
DockerAttacher.new(ARGV[0]).attach! |
Yeah using ruby and creating a class is overkill. ¯\_(ツ)_/¯
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
:)