func (c *Container) IsRunning(id string) bool {
	err := c.Inspect(id)
	if err != nil {
		return false
	}
	if !c.Docker.State.Running {
		return false
	}
	return true
}
Exists and IsRunning are wrapper of inspect
to get a precise state of the container
IsRunning is used to attach to it
package engine
import (
	"fmt"
	log "github.com/Sirupsen/logrus"
	dockerclient "github.com/fsouza/go-dockerclient"
	"github.com/jbdalido/smg/utils"
	"io"
	"math/rand"
	"runtime"
	"strconv"
	"strings"
	"time"
)
type Container struct {
	ID               string
	Image            ImageName
	Name             string
	Tags             []string
	Hostname         string
	Code             int
	Privileged       bool
	Protection       bool
	Client           *dockerclient.Client
	HostConfig       *dockerclient.HostConfig
	ContainerConfig  *dockerclient.Config
	Docker           *dockerclient.Container
	Ports            []dockerclient.Port
	WorkingDirectory string
	Links            []*Container
}
func (c *Container) Inspect(id string) error {
	cont, err := c.Client.InspectContainer(id)
	if err != nil {
		return err
	}
	c.Docker = cont
	c.Name = c.Docker.Name
	return nil
}
func (c *Container) Exists(id string) bool {
	err := c.Inspect(id)
	if err != nil {
		return false
	}
	return true
}